Explorar el Código

Fix crash on start without any accounts

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
(cherry picked from commit 9935606c87ec4818f04c7d7c63d2f4b61187eead)
Signed-off-by: Michael Schuster <michael@schuster.ms>
Dominique Fuchs hace 6 años
padre
commit
d3cd422b46
Se han modificado 3 ficheros con 16 adiciones y 3 borrados
  1. 6 1
      src/gui/owncloudgui.cpp
  2. 3 1
      src/gui/systray.cpp
  3. 7 1
      src/gui/tray/UserModel.cpp

+ 6 - 1
src/gui/owncloudgui.cpp

@@ -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

+ 3 - 1
src/gui/systray.cpp

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

+ 7 - 1
src/gui/tray/UserModel.cpp

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