Przeglądaj źródła

Merge pull request #4850 from nextcloud/bugfix/qml-error-logging-cpp

Prevent crashing when trying to create error-ing QML component in systray.cpp, output error to log
Claudio Cambra 3 lat temu
rodzic
commit
d44d839a26
1 zmienionych plików z 12 dodań i 2 usunięć
  1. 12 2
      src/gui/systray.cpp

+ 12 - 2
src/gui/systray.cpp

@@ -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);
@@ -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);
     }
 }