Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
QCoreApplication(int &argc, char **argv) implies that the caller (usually the main function) has to provide storage for argc but Qt is free to modify it. And in fact the QApplication constructor docs say "Note: argc and argv might be changed as Qt removes command line arguments that it recognizes." But does it have to be done like that? Seems like argc should be passed by value: an int is never larger than a pointer anyway, and that will ensure that Qt internalizes its own problem (counting the arguments) rather than imposing a (rude) requirement on the application author that "argc might be changed". And it's more or less source compatible.
What we see in QTBUG-56524 is that a user assumed it was OK to pass argc by value in a subclass (I guess). But it's not, because when the by-value constructor argument is given to the superclass constructor, this requirement is violated: Qt doesn't get to modify the original variable because it's temporary.
char **argv is convenient because every main() function has it. But it could be const: Qt should not modify either the pointer or the contents of that either.
Attachments
Issue Links
- resulted from
-
QTBUG-56524 Very strange crashes with QSystemTrayIcon
-
- Closed
-