Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 "Include default parameter values..." and Qt

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Queequeg Posted - Mar 01 2022 : 12:43:31 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 02 2022 : 08:01:36 AM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000