Static variables are only initialized once, when control passes over their definition for the first time¹. If they are initialized with non-static data, like the contents of a non-static data member, or the address of one, then all following uses of the object will continue to use the first control pass' data, even if the data members were from an object that has since been deleted. This whole construct appears to have worked merely because these functions are only executed once, or at least not on different objects. But better remove the dangerous construct while it hasn't broken something, yet, and before we e.g. make syncqt a library² or add a mode that makes it scan multiple modules at once. Requires to capture more variables in the parseArgument() lambda; more than fits into an explicit capture list, so use a [&] catch-all instead. As a drive-by, use CTAD to not have to mention the number of elements in a std::array, but have the compiler deduce them, and add const, where it's missing. Amends b89d63515bb352cecfd87e709320a2db5b6a1906 (and maybe a few in-between, we'll see when cherry-picking). ¹ Except corner-case like when initialization fails by throwing an exception. ² see similar ideas for moc, e.g.: QTBUG-132820 Pick-to: 6.9 6.8 6.5 Change-Id: I65a73059151e3d39341939f613080e6d833a4c30 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
…
…
Description
Languages
C++
84.3%
HTML
4.9%
C
3.9%
CMake
3.6%
Objective-C++
2%
Other
0.8%