From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sat, 18 Jan 2020 17:17:43 +0000 (+0100) Subject: Fix crash on start without any accounts X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~405 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d3cd422b46bed0445ab9b4662a56a829814a61bd;p=nextcloud-desktop.git 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 --- diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index f4f37ba1a..d271059ab 100644 --- a/src/gui/owncloudgui.cpp +++ b/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 diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index be0253ddb..6134adcee 100644 --- a/src/gui/systray.cpp +++ b/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(); } diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index 2c66894e6..b7dbc8fed 100644 --- a/src/gui/tray/UserModel.cpp +++ b/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(); } }