Commit Graph

7 Commits

Author SHA1 Message Date
Sebastian Beckmann
649beed45c frontend: Don't store QT_TO_UTF8 to std::string
QT_TO_UTF8 returns a const char * that, in general, shouldn't be stored.
This is because QT_TO_UTF8(str) expands to str.toUtf8().constData():
toUtf8() returns a QByteArray, and constData() the pointer to its data
which is only valid until the QByteArray goes out of scope, which is
immediately after the call.
The original code that is changed here only works because in all of the
situations, the object that is stored to is actually a std::string that
gets constructed implicitly, so the constData() pointer is valid long
enough for the std::string constructor to copy the data.

The issue is that any "... = QT_TO_UTF8" code *looks* unsafe, and may
lead new or unfamiliar contributors to assume that they can also use it,
only to do "const char *... = QT_TO_UTF8(...)" which is dangerous.
Additionally, it introduces an unnecessary round of implicit conversions
and copies when QString.toStdString() already exists and copies into the
string buffer directly.
2026-05-06 14:15:44 -04:00
Ryan Foster
9bd4514b45 frontend: Ensure cookie ID is always 16 hexadecimal characters
At a glance, the GenId function looks like it can only return a
16-character hexadecimal string with all characters being [0-9A-F].
However, it seems that it can rarely return a 16-character string that
has one or two space characters at the beginning due to the value of id,
from which the final string is derived, being too low (lower than
1152921504606846976 or 0x1000000000000000) and the printf format
specifier having a width of 16. This results in a string of less than 16
characters that is padded with blank spaces. The end result is a cookie
directory that has leading spaces in its name, which can cause various
issues, such as breaking syncing on OneDrive.

If we set the format specifier to pad with zeroes instead of spaces, the
resulting hexadecimal value is always 16 characters long without spaces.
2025-05-28 12:42:22 -04:00
PatTheMav
1c4b60057e frontend: Finalize merge of OBSBasic Sources with module sources 2025-01-08 17:35:16 +01:00
PatTheMav
9b8517003b frontend: Merge main OBSBasic source with module sources 2025-01-08 17:34:46 +01:00
PatTheMav
654ddcd409 frontend: Split Qt UI Widget implementations into single files per class 2025-01-08 17:33:13 +01:00
PatTheMav
9f887c76d3 frontend: Prepare Qt UI Widgets for splits 2025-01-08 17:33:13 +01:00
PatTheMav
664a719421 frontend: Prepare sources for merge with OBSBasic modules 2025-01-08 15:37:22 +01:00