Commit 9784f12b authored by Fushan Wen's avatar Fushan Wen
Browse files

wallpapers/potd: fix not updating wallpaper in lock screen

Skip updating wallpapers in client's ctor. Call `setUpdateOverMeteredConnection`
or `updateSource` in `PotdBackend::registerClient()` , to ensure only
one loading process will be run at the same time.

BUG: 457361
FIXED-IN: 5.26


(cherry picked from commit 20c0881e)
parent 50719ce0
Pipeline #236769 passed with stage
in 2 minutes and 17 seconds
......@@ -169,18 +169,20 @@ int PotdBackend::doesUpdateOverMeteredConnection() const
void PotdBackend::setUpdateOverMeteredConnection(int value)
{
if (m_doesUpdateOverMeteredConnection == std::clamp(value, 0, 2)) {
return;
value = std::clamp(value, 0, 2);
const bool changed = m_doesUpdateOverMeteredConnection != value;
if (changed) {
m_doesUpdateOverMeteredConnection = value;
Q_EMIT updateOverMeteredConnectionChanged();
}
m_doesUpdateOverMeteredConnection = std::clamp(value, 0, 2);
Q_EMIT updateOverMeteredConnectionChanged();
#if HAVE_NetworkManagerQt
if (m_ready && m_client) {
#if HAVE_NetworkManagerQt
m_client->setUpdateOverMeteredConnection(m_doesUpdateOverMeteredConnection);
}
#else
m_client->updateSource();
#endif
}
}
void PotdBackend::saveImage()
......@@ -290,9 +292,6 @@ void PotdBackend::registerClient()
Q_EMIT titleChanged();
Q_EMIT authorChanged();
#if HAVE_NetworkManagerQt
if (m_client) {
m_client->setUpdateOverMeteredConnection(m_doesUpdateOverMeteredConnection);
}
#endif
// For updateSource()
setUpdateOverMeteredConnection(m_doesUpdateOverMeteredConnection);
}
......@@ -37,7 +37,8 @@ PotdClient::PotdClient(const KPluginMetaData &metadata, const QVariantList &args
, m_identifier(metadata.value(QStringLiteral("X-KDE-PlasmaPoTDProvider-Identifier")))
, m_args(args)
{
updateSource();
// updateSource() will be called in PotdClient::setUpdateOverMeteredConnection(bool)
// or PotdBackend::setUpdateOverMeteredConnection(bool)
}
void PotdClient::updateSource(bool refresh)
......@@ -100,7 +101,8 @@ void PotdClient::setUpdateOverMeteredConnection(int value)
// the wallpaper.
m_doesUpdateOverMeteredConnection = value;
if (m_doesUpdateOverMeteredConnection == 1 && isUsingMeteredConnection()) {
const bool metered = isUsingMeteredConnection();
if (m_doesUpdateOverMeteredConnection == 1 || (m_doesUpdateOverMeteredConnection == 0 && !metered)) {
updateSource();
}
}
......
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