Check that QIODevice::open() is successful, and explicitly call close()

This commit is contained in:
Jonas Kvinge
2021-07-14 20:52:57 +02:00
parent f64c1dd9e5
commit 2eab763d74
15 changed files with 74 additions and 49 deletions

View File

@@ -124,14 +124,16 @@ SmartPlaylistSearchTermWidget::SmartPlaylistSearchTermWidget(CollectionBackend *
// Set stylesheet
QFile stylesheet_file(":/style/smartplaylistsearchterm.css");
stylesheet_file.open(QIODevice::ReadOnly);
QString stylesheet = QString::fromLatin1(stylesheet_file.readAll());
const QColor base(222, 97, 97, 128);
stylesheet.replace("%light2", Utilities::ColorToRgba(base.lighter(140)));
stylesheet.replace("%light", Utilities::ColorToRgba(base.lighter(120)));
stylesheet.replace("%dark", Utilities::ColorToRgba(base.darker(120)));
stylesheet.replace("%base", Utilities::ColorToRgba(base));
setStyleSheet(stylesheet);
if (stylesheet_file.open(QIODevice::ReadOnly)) {
QString stylesheet = QString::fromLatin1(stylesheet_file.readAll());
stylesheet_file.close();
const QColor base(222, 97, 97, 128);
stylesheet.replace("%light2", Utilities::ColorToRgba(base.lighter(140)));
stylesheet.replace("%light", Utilities::ColorToRgba(base.lighter(120)));
stylesheet.replace("%dark", Utilities::ColorToRgba(base.darker(120)));
stylesheet.replace("%base", Utilities::ColorToRgba(base));
setStyleSheet(stylesheet);
}
}