Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 "Include default parameter values..." and Qt
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Queequeg
Senior Member

Germany
36 Posts

Posted - Mar 01 2022 :  12:43:31 PM  Show Profile  Reply with Quote
VA uses the format
void f(int x /*= 0*/)
for the default parameter values but this conflicts with Qt's localization tools.

The way VA formats these comments resulted in the following bug, which was quite hard to track down. The code looked as follows:
void Class::func(const char* syntax /*= nullptr*/)
{
  initializeStuff(QObject::tr("Initialize network"));
  // ...
}
The bug was that this string was never translated when we ran the software. Why was this?

Well, turns out due to the unrelated comment in the line before, Qt thinks that the string has the id "nullptr". Cf. https://doc.qt.io/qt-5/i18n-source-translation.html#adding-meta-data-to-strings. But of course this id is not unique. We have other code that VA formatted this way, e. g. this one:
MyWidget(parent /*= nullptr*/)
: Dialog(tr("My widget"))
{}
So, because there already exists a string with the id "nullptr", Qt will ignore any other string with the same id.

I found a related topic here: https://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=9091. Feline, you mentioned that it's possible to edit the snippets. However, I couldn't find a snippet related to the way the comment is formatted.

My request would be to change the formatting to something like this:
void f(int x/* =0*/)
or
void f(int x/* =0 */)
in order to avoid the /*=.

Edit: Nevermind. There's a bug report in Qt, and it looks like they fixed it in 5.2. https://bugreports.qt.io/browse/QTBUG-11866 https://bugreports.qt.io/browse/QTBUG-15770

Edited by - Queequeg on Mar 01 2022 12:54:14 PM

feline
Whole Tomato Software

United Kingdom
19073 Posts

Posted - Mar 02 2022 :  08:01:36 AM  Show Profile  Reply with Quote
Thank you for the update, are you able to move to Qt 5.2 or above?

VA Snippets will let you control some formatting, but unfortunately not the formatting of the commented out parameter, so that isn't a work around for this.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000