View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017486 | Scribus | Build System | public | 2025-04-02 19:06 | 2025-04-03 19:19 |
Reporter | nitramr | Assigned To | jghali | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | Desktop PC | OS | Ubuntu | OS Version | 24.10 64-bit |
Product Version | 1.7.1.svn | ||||
Target Version | 1.7 milestone | Fixed in Version | 1.7.1.svn | ||
Summary | 0017486: Compiler error when building with Qt 6.9.0 | ||||
Description | QString::arg(Args &&... args) was changed in Qt 6.9.0 and Scribus could not compile. See https://doc.qt.io/qt-6/qstring.html#arg | ||||
Tags | No tags attached. | ||||
Patch | Yes | ||||
|
buildfix_2025-04-02_01.patch (452 bytes)
Index: scribus/util_text.cpp =================================================================== --- scribus/util_text.cpp (Revision 26822) +++ scribus/util_text.cpp (Arbeitskopie) @@ -99,8 +99,8 @@ { QString out; - for (auto c : text) - out += QString("U+%1,").arg(c.unicode(), 4, 16, QChar('0')).toUpper(); + for (auto c : text.toUcs4()) + out += QString("U+%1,").arg(c, 4, 16, QChar('0')).toUpper(); return out.mid(0, out.length() -1); |
|
This patch is not correct, c.unicode() returns a char16_t, so text.toUcs4() cannot be correct. |
|
The proper approach here is probably to static_cast c.unicode() to a ushort or a uint in order to select proper QString::arg() overload. In this case, we do not want to use QString::arg(Args &&... args) but rather QString::arg(uint a, int fieldWidth = 0, int base = 10, QChar fillChar = u' '). |
|
Using a static_cast was indeed the solution. |
|
Thanks for taking a look. Does it really make a difference if each character is converted to a uint at the end instead of the entire string at the beginning? |
|
as written in the chat, i would go forout += QString("U+%1,").arg(QString::number(c.unicode(), 16).toUpper(), 4, QChar('0')); ... if it works in Qt 6.9... |
|
>> Does it really make a difference if each character is converted to a uint at the end instead of the entire string at the beginning? Yes, because the encodings used by QString and QString::toUcs4() are not the same. In QStrings, character data is encoded using UTF-16, with each QChar having a value between 0 and 65535, while QString::toUcs4() encodes data as UTF-32 with each character being encoded as a uint value. Now comes the case of characters such as emojis which are encoded with a value > 65535 in UTF-32. For such character, a single QChar will not be sufficient for the encoding in UTF-16, so several QChars will be used instead of a single one. This is the concept of UTF-16 surrogate pairs, with high and low surrogates. So for these king of characters: - several QChar are needed in UTF-16 vs a single uint value in UTF-32 : so the toUcs4() version of the function would not lead to the same result as the original function - due to characters being encoded in UTF-32 with value possibly > 65535, the .arg(c, 4, 16, QChar('0')) call would not be correct as only two bytes of the UTF-32 value would be processed |
|
Thanks for the detailed explanation. |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-04-02 19:06 | nitramr | New Issue | |
2025-04-02 19:06 | nitramr | Status | new => assigned |
2025-04-02 19:06 | nitramr | Assigned To | => nitramr |
2025-04-02 19:06 | nitramr | File Added: buildfix_2025-04-02_01.patch | |
2025-04-02 22:01 | jghali | Note Added: 0052384 | |
2025-04-02 22:07 | jghali | Note Added: 0052385 | |
2025-04-02 22:07 | jghali | Note Edited: 0052385 | |
2025-04-02 22:27 | jghali | Assigned To | nitramr => jghali |
2025-04-02 22:27 | jghali | Status | assigned => resolved |
2025-04-02 22:27 | jghali | Resolution | open => fixed |
2025-04-02 22:27 | jghali | Fixed in Version | => 1.7.1.svn |
2025-04-02 22:27 | jghali | Note Added: 0052386 | |
2025-04-02 22:36 | jghali | Summary | Compiler error for Qt 6.9.0 => Compiler error when building with Qt 6.9.0 |
2025-04-03 18:30 | nitramr | Note Added: 0052388 | |
2025-04-03 18:53 | ale | Note Added: 0052389 | |
2025-04-03 19:12 | jghali | Note Added: 0052390 | |
2025-04-03 19:19 | nitramr | Note Added: 0052391 |