Fix crash on start without any accounts
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 18 Jan 2020 17:17:43 +0000 (18:17 +0100)
committerMichael Schuster <michael@schuster.ms>
Sun, 19 Jan 2020 13:14:23 +0000 (14:14 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
(cherry picked from commit 9935606c87ec4818f04c7d7c63d2f4b61187eead)
Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/owncloudgui.cpp
src/gui/systray.cpp
src/gui/tray/UserModel.cpp

index f4f37ba1ae7479de7196a2f9c886f88a9253ecf1..d271059ab01861f27cca1eaa7db2d147ffc9ae88 100644 (file)
@@ -166,7 +166,12 @@ void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
         } else if (_tray->isOpen()) {
             _tray->hideWindow();
         } else {
-            _tray->showWindow();
+            if (AccountManager::instance()->accounts().isEmpty()) {
+                this->slotOpenSettingsDialog();
+            } else {
+                _tray->showWindow();
+            }
+
         }
     }
     // FIXME: Also make sure that any auto updater dialogue https://github.com/owncloud/client/issues/5613
index be0253ddba64fb5b0c8780b70b012a610f01464b..6134adceec74314e983577fe2464862223817358 100644 (file)
@@ -72,7 +72,9 @@ Systray::Systray()
 void Systray::create()
 {
     if (_trayContext == nullptr) {
-        _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+        if (!AccountManager::instance()->accounts().isEmpty()) {
+            _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+        }
         _trayContext = _trayEngine->contextForObject(_trayComponent->create());
         hideWindow();
     }
index 2c66894e63ef5f664695fc86f5bde955ad203f9d..b7dbc8fed12ad011f1a1ecb9a028f5940a10244c 100644 (file)
@@ -551,7 +551,12 @@ Q_INVOKABLE int UserModel::currentUserId()
 
 Q_INVOKABLE bool UserModel::isUserConnected(const int &id)
 {
-    return _users[id]->isConnected();
+    if (!_users.isEmpty()) {
+        return _users[id]->isConnected();
+    } else {
+        return false;
+    }
+
 }
 
 Q_INVOKABLE QImage UserModel::currentUserAvatar()
@@ -620,6 +625,7 @@ void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent)
         endInsertRows();
         ConfigFile cfg;
         _users.last()->setNotificationRefreshInterval(cfg.notificationRefreshInterval());
+        emit newUserSelected();
     }
 }