Fix crash on start without any accounts

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
(cherry picked from commit 9935606c87)
Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
Dominique Fuchs 2020-01-18 18:17:43 +01:00 committed by Michael Schuster
parent 482ab9ad14
commit d3cd422b46
No known key found for this signature in database
GPG Key ID: 00819E3BF4177B28
3 changed files with 16 additions and 3 deletions

View 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

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

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