Commit 766d220d authored by Amy Rose's avatar Amy Rose Committed by Fushan Wen
Browse files

applets/kicker: refresh RootModel on session backend state change

BUG: 427530

Hunting this one down since mid-March...

In "native" Plasma containments like the panel, desktop, and plasmawindowed, the `LogindSessionBackend` in `libkworkspace` enters the "Ready" state nearly instantly, before any signals can even be attached. In other containments like Latte Dock and plasmoidviewer, however, the initialization takes some time to complete (unsure why). RootModel was not watching or waiting to check what the session backend's state was, resulting in validity checks being done too soon and never checked again.


(cherry picked from commit 2cc819f3)
parent ae7adb36
Pipeline #177506 passed with stage
in 10 minutes and 43 seconds
......@@ -449,6 +449,7 @@ void RootModel::refresh()
}
m_systemModel = new SystemModel(this);
QObject::connect(m_systemModel, &SystemModel::sessionManagementStateChanged, this, &RootModel::refresh);
if (m_showPowerSession) {
m_entryList << new GroupEntry(this, i18n("Power / Session"), QStringLiteral("system-log-out"), m_systemModel);
......
......@@ -79,6 +79,7 @@ void SystemEntry::refresh()
{
if (!s_sessionManagement) {
s_sessionManagement = new SessionManagement();
QObject::connect(s_sessionManagement, &SessionManagement::stateChanged, this, &SystemEntry::sessionManagementStateChanged);
}
bool valid = false;
......
......@@ -54,6 +54,7 @@ public:
Q_SIGNALS:
void isValidChanged() const;
void sessionManagementStateChanged();
private Q_SLOTS:
void refresh();
......
......@@ -92,10 +92,12 @@ void SystemModel::populate()
auto addIfValid = [=](const SystemEntry::Action action) {
SystemEntry *entry = new SystemEntry(this, action);
QObject::connect(entry, &SystemEntry::sessionManagementStateChanged, this, &SystemModel::sessionManagementStateChanged);
if (entry->isValid()) {
m_entries << entry;
}
QObject::connect(entry, &SystemEntry::isValidChanged, this, &AbstractModel::refresh, Qt::UniqueConnection);
};
......
......@@ -25,6 +25,9 @@ public:
Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override;
Q_SIGNALS:
void sessionManagementStateChanged();
protected Q_SLOTS:
void refresh() override;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment