Skip to content

fix: resolve QStringBuilder type mismatch in ternary operator#4311

Open
SD191100 wants to merge 1 commit into
fritzing:developfrom
SD191100:fix/qstringbuilder-ternary-mismatch
Open

fix: resolve QStringBuilder type mismatch in ternary operator#4311
SD191100 wants to merge 1 commit into
fritzing:developfrom
SD191100:fix/qstringbuilder-ternary-mismatch

Conversation

@SD191100
Copy link
Copy Markdown

Description

Fixes a compilation failure occurring under explicit compilation configurations where QT_USE_QSTRINGBUILDER is 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 concatenated QString expression on the right branch. Under QT_USE_QSTRINGBUILDER optimizations, the right-hand expression evaluates as a lazy QStringBuilder template 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

@SD191100 SD191100 changed the title fix: resolve QStringBuild3er typ mismatch in ternary operator fix: resolve QStringBuildeer type mismatch in ternary operator May 18, 2026
@SD191100 SD191100 changed the title fix: resolve QStringBuildeer type mismatch in ternary operator fix: resolve QStringBuilder type mismatch in ternary operator May 18, 2026
@sonarqubecloud
Copy link
Copy Markdown

@KjellMorgenstern
Copy link
Copy Markdown
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants