fix: resolve QStringBuilder type mismatch in ternary operator#4311
fix: resolve QStringBuilder type mismatch in ternary operator#4311SD191100 wants to merge 1 commit into
Conversation
|
|
The change itself seems trivial, I'll include it for 1.0.8. The main question remainig is, why enforce QT_USE_QSTRINGBUILDER ? Is there any issue without it, did you run any measurements? |
|
To clarify, I didn't manually enable the flag—QT_USE_QSTRINGBUILDER is actually defined directly within Fritzing's own project build configuration files. When I cloned the repo and tried to build it locally, the compilation failed consistently at that line because of how that ternary operator was interacting with the project's enabled optimizations so i tried adding type parity and it worked. I did not do any custom measurements, i just fixed a building error at my end, and thought if same is occurs with others, my solution might help. If you think i should do some measurements or testing, please let me know, this is new for me and i am trying to learn here. Thanks |



Description
Fixes a compilation failure occurring under explicit compilation configurations where
QT_USE_QSTRINGBUILDERis enforced.Problem
At line 837 in
src/utils/folderutils.cpp, a ternary conditional operator (? :) evaluates an empty string literal(const char*)on the left branch, and a concatenatedQStringexpression on the right branch. UnderQT_USE_QSTRINGBUILDERoptimizations, the right-hand expression evaluates as a lazyQStringBuildertemplate type. Because C++ strict type resolution requires uniform type yields across both conditional evaluation paths, the compiler throws a fatal initialization error due to type mismatch.The Solution
Explicitly returned an optimized, default-constructed
QString("")on the true branch evaluation block to satisfy type parity across compiler configurations.note: This is my very first Pull Request to an open-source project. If there are any project-specific formatting preferences, commit linting styles, or documentation guidelines I missed, please let me know