[Development] Q_FOREACH, again

Ahmad Samir a.samirh78 at gmail.com
Mon Aug 14 22:38:41 CEST 2023


On 14/8/23 21:46, Thiago Macieira wrote:
> On Monday, 14 August 2023 10:32:36 PDT Marc Mutz via Development wrote:
>> It does _not_ have any influence on user code.
> 
> Except where accidentally the QT_NO_FOREACH gets copied to the library's CMake
> INTERFACE. Then it does. This happened for QT_NO_CONTEXTLESS_CONNECT when it
> was applied to Qt6UiPlugin.
> 
> We don't understand why it happened there (didn't bother to investigate), so
> be aware that your claim may be incorrect and that user code may be affected
> regardless of your intention.
> 
> See 93de403391b59acf90fbe7319a059382dfe458a6 in the qt-creator repository.
> 
> 

Thanks to Giuseppe for poking the issue, Alexandru figured it out a while ago: 
https://codereview.qt-project.org/c/qt/qttools/+/491477/2/src/uiplugin/CMakeLists.txt#16

The issue seen in Qt Creator 93de403391b59acf90fbe7319a059382dfe458a6 (the 
QT_NO_CONTEXTLESS_CONNECT leaking to user code) was "fixed" by 
https://codereview.qt-project.org/c/qt/qttools/+/492556

The "gist" of it is, don't use qt_internal_add_module + HEADER_MODULE + DEFINES, 
because those DEFINES could be leaked into user code that links to the plugin in 
question.

HEADER_MODULE isn't used that many times in Qt code, and typically where it's used 
there is no SOURCES arg passed to qt_internal_add_module, however it's a corner 
case to look out for when adding DEFINES to qt_internal_add_module.

Regards,
Ahmad Samir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230814/1c672810/attachment.sig>


More information about the Development mailing list