Skip to content

Commit

Permalink
Prevent crashing when trying to create error-ing QML component in sys…
Browse files Browse the repository at this point in the history
…tray.cpp, output error to log

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
  • Loading branch information
claucambra committed Aug 16, 2022
1 parent ff7331a commit 0b2829d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ void Systray::create()
}

QQmlComponent trayWindowComponent(_trayEngine, QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
_trayWindow.reset(qobject_cast<QQuickWindow*>(trayWindowComponent.create()));

if(trayWindowComponent.isError()) {
qCWarning(lcSystray) << trayWindowComponent.errorString();
} else {
_trayWindow.reset(qobject_cast<QQuickWindow*>(trayWindowComponent.create()));
}
}
hideWindow();
emit activated(QSystemTrayIcon::ActivationReason::Unknown);
Expand Down Expand Up @@ -260,8 +265,13 @@ void Systray::createCallDialog(const Activity &callNotification, const AccountSt
};

const auto callDialog = new QQmlComponent(_trayEngine, QStringLiteral("qrc:/qml/src/gui/tray/CallNotificationDialog.qml"));
callDialog->createWithInitialProperties(initialProperties);

if(callDialog->isError()) {
qCWarning(lcSystray) << callDialog->errorString();
return;
}

callDialog->createWithInitialProperties(initialProperties);
_callsAlreadyNotified.insert(callNotification._id);
}
}
Expand Down

0 comments on commit 0b2829d

Please sign in to comment.