Fix crash when the notification file is empty. Fix warning when running with Qt version newer than 6.7

This commit is contained in:
Alexander Bock
2025-04-17 20:20:13 +02:00
parent 78efc7b244
commit e4eebaef7e
2 changed files with 24 additions and 2 deletions

View File

@@ -66,6 +66,11 @@ namespace {
std::vector<Entry> entries;
std::vector<std::string> lines = ghoul::tokenizeString(data, '\n');
if (lines.empty() || lines[0].empty()) {
// The notification file is empty and we don't want to show anything
return entries;
}
std::vector<std::string>::const_iterator curr = lines.cbegin();
while (curr != lines.end()) {
Entry e = parseEntry(curr);
@@ -89,7 +94,7 @@ namespace {
text = text.darker();
if (date::sys_days(ymd) < date::sys_days(lastStartedDate)) {
QColor text = QColor(120, 120, 120);
const QColor textColor = QColor(120, 120, 120);
return std::format(
"<tr>"
"<td width='15%'>"
@@ -99,7 +104,7 @@ namespace {
"<font color='#{2:x}{3:x}{4:x}'>{1}</font>"
"</td>"
"</tr>",
e.date, e.text, text.red(), text.green(), text.blue()
e.date, e.text, textColor.red(), textColor.green(), textColor.blue()
);
}
else {

View File

@@ -108,9 +108,14 @@ void SettingsDialog::createWidgets() {
"If this setting is checked, the application will remember the profile that "
"was loaded into OpenSpace and will use it at the next startup as well"
);
connect(
_rememberLastProfile,
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
&QCheckBox::checkStateChanged,
#else // ^^^^ >=6.7.0 // !WIN32 <6.7.0
&QCheckBox::stateChanged,
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
[this]() {
if (_rememberLastProfile->isChecked()) {
_currentEdit.rememberLastProfile = true;
@@ -166,7 +171,11 @@ void SettingsDialog::createWidgets() {
);
connect(
_rememberLastConfiguration,
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
&QCheckBox::checkStateChanged,
#else // ^^^^ >=6.7.0 // !WIN32 <6.7.0
&QCheckBox::stateChanged,
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
[this]() {
if (_rememberLastConfiguration->isChecked()) {
_currentEdit.rememberLastConfiguration = true;
@@ -241,7 +250,11 @@ void SettingsDialog::createWidgets() {
);
connect(
_bypassLauncher,
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
&QCheckBox::checkStateChanged,
#else // ^^^^ >=6.7.0 // !WIN32 <6.7.0
&QCheckBox::stateChanged,
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
[this]() {
if (_bypassLauncher->isChecked()) {
_currentEdit.bypassLauncher = _bypassLauncher->isChecked();
@@ -313,7 +326,11 @@ void SettingsDialog::createWidgets() {
);
connect(
_mrf.isEnabled,
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
&QCheckBox::checkStateChanged,
#else // ^^^^ >=6.7.0 // !WIN32 <6.7.0
&QCheckBox::stateChanged,
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
[this]() {
if (_mrf.isEnabled->isChecked()) {
_currentEdit.mrf.isEnabled = _mrf.isEnabled->isChecked();