BUG: Do not discard the RESOURCES of a plug-in - #1443
Conversation
|
It is an interesting experience to review the result of someone else's AI chatbot session. Using AI is of course the right thing to do, but it generates very verbose and somewhat inaccurate results. Since I don't want to waste my time, I need to start my own AI session to pose questions and challenge potential inaccuracies and improve the solution. But then @kislinsk you don't have access to that session and you'll again need to start another discussion to review the results and ask your own questions. All these iterations take much longer than the direct human code writing and review... Let's see if we can have a shared AI-assisted discussion here to avoid the private AI sessions. I'll try to summon the copilot agent with some questions to see if it leads a more efficient workflow. |
lassoan
left a comment
There was a problem hiding this comment.
The change is correct but consider adding more accurate details in the commit comment (see my previous comment).
The macro cleared MY_RESOURCES immediately after argument parsing: # Make sure variable are cleared set(MY_RESOURCES) Since MY_RESOURCES holds the caller's RESOURCES argument, the clear discarded every .qrc file a plug-in passed in. Only the generated manifest and cached-resource .qrc files were appended afterwards, so the plug-in's own .qrc files never became target sources and AUTORCC never compiled them. The failure is silent: configure, build, link and plug-in loading all succeed, and only runtime resource lookups fail (e.g. "Could not read :/org.blueberry.ui.qt/darkstyle.qss"). Why the clearing existed: fd4845f (2010) added it for the OUTPUT variables of the Qt wrap macros (MY_UI_CXX, MY_QRC_SRCS, MY_MOC_CPP). Those names are not in the CtkMacroParseArguments keyword list, so nothing initialized them, and the Qt wrap macros append to their output variable instead of assigning it. Because ctkMacroBuildPlugin is an unscoped macro(), a second invocation in the same directory scope would append onto the previous plug-in's generated-file list. For those variables the manual clear was the only defense. Why it is no longer needed: the Qt6-prep commits (37f5f51 AUTOUIC, 1758736 AUTORCC, b33c233 AUTOMOC) removed the explicit wrap calls, and with them every such output variable. The only variables left in the macro are parsed keywords, which CtkMacroParseArguments already resets unconditionally at the start of every call, so no stale value can leak between invocations. Why it broke now: 1758736 renamed the clear from set(MY_QRC_SRCS) (a generated-output list, correct to clear) to set(MY_RESOURCES) (the parsed input, wrong to clear) while migrating to AUTORCC. The same mistake was made and fixed once before: fd4845f also cleared MY_SRCS, and e588f21 removed that clear the same day because parsed inputs must not be cleared. There is no correct placement for the clear - before parsing it duplicates what the parser does, after parsing it discards the input - so it is deleted. In-tree plug-ins do not catch this because the only one passing a real .qrc via RESOURCES (org.commontk.dah.core) is OFF by default.
6588b7f to
ca28e09
Compare
|
Thank you for looking into the PRs so quickly. I know it's not the best etiquette to drop a whole bunch of AI-generated PRs on you. Sometimes I forget that we probably have very different perspectives on CTK. Things that seem obvious to us can be difficult for you to understand, and vice versa. I've amended the commit to use your commit message. It is indeed much easier to understand. |

Disclaimer: We (MITK) are currently catching up on the latest CTK master branch
since we forked for Qt 6 back in 2023. We found a few bugs that are not caught by
your CI and mostly affect external users of CTK.
Priority: highest. Regression that makes
ctkMacroBuildPluginsilentlyignore a documented parameter.
ctkMacroBuildPluginacceptsRESOURCES, but clears the variable before use:Only the generated manifest and cached-resource
.qrcfiles are appendedafterwards, so a plug-in's own
.qrcfiles never become target sources andAUTORCC never compiles them. Every icon, stylesheet and other embedded file of
a plug-in is missing at runtime.
The clearing made sense while the macro compiled
RESOURCESinto a separatelist of generated sources (
MY_QRC_SRCS); with AUTORCC the.qrcfilesthemselves are the target sources, so the reset just drops them.
Why CI does not catch it: the in-tree plug-ins pass no
RESOURCES(
set(PLUGIN_resources )is empty in bothorg.commontk.eventadminandorg.commontk.configadmin), so nothing exercises the parameter.How it presents: builds and links without a single warning. The plug-in
loads, and only at runtime does every resource lookup fail:
Verifiable in the build tree: no
qrc_<name>.cppis generated for theplug-in's own
.qrc, only the_cachedand_manifestones.