mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Add check if monitor index exists before starting
This can happen when the user has a valid config and removes one monitor with an active wallpaper while ScreenPlay is not running.
This commit is contained in:
parent
305026982a
commit
134a04979e
@ -111,6 +111,17 @@ bool ScreenPlayManager::createWallpaper(
|
||||
const QJsonObject& properties,
|
||||
const bool saveToProfilesConfigFile)
|
||||
{
|
||||
const int screenCount = QGuiApplication::screens().count();
|
||||
|
||||
QJsonArray monitors;
|
||||
for (const int index : monitorIndex) {
|
||||
monitors.append(index);
|
||||
if (index > screenCount - 1) {
|
||||
qWarning() << "Configuration contains invalid monitor with index: " << index << " screen count: " << screenCount;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto saveToProfile = qScopeGuard([=, this] {
|
||||
// Do not save on app start
|
||||
if (saveToProfilesConfigFile) {
|
||||
@ -118,11 +129,6 @@ bool ScreenPlayManager::createWallpaper(
|
||||
}
|
||||
});
|
||||
|
||||
QJsonArray monitors;
|
||||
for (const int index : monitorIndex) {
|
||||
monitors.append(index);
|
||||
}
|
||||
|
||||
const QString path = QUrl::fromUserInput(absoluteStoragePath).toLocalFile();
|
||||
const QString appID = ScreenPlayUtil::generateRandomString();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user