From 5af4b0c40c27e9e57e6e148c11035cae17ca18ac Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 4 Mar 2016 15:06:12 +0300 Subject: [PATCH] fix bug introduced by lazy subscription Sources in custom dataengine updated only if user subscribe on specified source. I've implemented drop returing value so if no requested value found it will return force update event. --- sources/extsysmon/sources/batterysource.cpp | 5 +++-- sources/extsysmon/sources/playersource.cpp | 5 +++-- sources/extsysmon/sources/processessource.cpp | 5 +++-- sources/extsysmon/sources/quotessource.cpp | 10 ++++++---- sources/extsysmon/sources/weathersource.cpp | 10 ++++++---- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/sources/extsysmon/sources/batterysource.cpp b/sources/extsysmon/sources/batterysource.cpp index 647b3f3..af4da45 100644 --- a/sources/extsysmon/sources/batterysource.cpp +++ b/sources/extsysmon/sources/batterysource.cpp @@ -44,9 +44,10 @@ QVariant BatterySource::data(QString source) { qCDebug(LOG_ESM) << "Source" << source; - if (source == QString("battery/ac")) + if (!values.contains(source)) run(); - return values[source]; + QVariant value = values.take(source); + return value; } diff --git a/sources/extsysmon/sources/playersource.cpp b/sources/extsysmon/sources/playersource.cpp index c580a2d..2039e25 100644 --- a/sources/extsysmon/sources/playersource.cpp +++ b/sources/extsysmon/sources/playersource.cpp @@ -52,9 +52,10 @@ QVariant PlayerSource::data(QString source) { qCDebug(LOG_ESM) << "Source" << source; - if (source == QString("player/title")) + if (!values.contains(source)) run(); - return values[source]; + QVariant value = values.take(source); + return value; } diff --git a/sources/extsysmon/sources/processessource.cpp b/sources/extsysmon/sources/processessource.cpp index 4f41cb9..a84687c 100644 --- a/sources/extsysmon/sources/processessource.cpp +++ b/sources/extsysmon/sources/processessource.cpp @@ -41,9 +41,10 @@ QVariant ProcessesSource::data(QString source) { qCDebug(LOG_ESM) << "Source" << source; - if (source == QString("ps/running/count")) + if (!values.contains(source)) run(); - return values[source]; + QVariant value = values.take(source); + return value; } diff --git a/sources/extsysmon/sources/quotessource.cpp b/sources/extsysmon/sources/quotessource.cpp index a9d8129..fff4473 100644 --- a/sources/extsysmon/sources/quotessource.cpp +++ b/sources/extsysmon/sources/quotessource.cpp @@ -45,13 +45,15 @@ QVariant QuotesSource::data(QString source) { qCDebug(LOG_ESM) << "Source" << source; - if (source.startsWith(QString("quotes/percpricechg"))) { - QVariantHash data = extQuotes->itemByTagNumber(index(source))->run(); + int ind = index(source); + source.remove(QString("quotes/")); + if (!values.contains(source)) { + QVariantHash data = extQuotes->itemByTagNumber(ind)->run(); for (auto key : data.keys()) values[key] = data[key]; } - QString key = QString(source).remove(QString("quotes/")); - return values[key]; + QVariant value = values.take(source); + return value; } diff --git a/sources/extsysmon/sources/weathersource.cpp b/sources/extsysmon/sources/weathersource.cpp index 9a57851..13a1fc6 100644 --- a/sources/extsysmon/sources/weathersource.cpp +++ b/sources/extsysmon/sources/weathersource.cpp @@ -45,13 +45,15 @@ QVariant WeatherSource::data(QString source) { qCDebug(LOG_ESM) << "Source" << source; - if (source.startsWith(QString("weather/weatherId"))) { - QVariantHash data = extWeather->itemByTagNumber(index(source))->run(); + int ind = index(source); + source.remove(QString("weather/")); + if (!values.contains(source)) { + QVariantHash data = extWeather->itemByTagNumber(ind)->run(); for (auto key : data.keys()) values[key] = data[key]; } - QString key = QString(source).remove(QString("weather/")); - return values[key]; + QVariant value = values.take(source); + return value; }