summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-04-03 12:20:43 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2025-04-10 18:46:01 +0200
commit01ced9d45ab87f5d3fd41525621c680965517ee7 (patch)
treeab77c2f6944ca00cadc33a1d4c630aacc85e8eba /src/corelib/kernel/qmetaobject.cpp
parent4392e5f4c5b4806051f5d4c70de423133dfd2d86 (diff)
syncqt.cpp: don't init static variables with non-static data
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>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
0 files changed, 0 insertions, 0 deletions