OSDN Git Service

kdeplasma-addons: stop emitting the finished signal of WeatherLocation once a valid...
authorIvailo Monev <xakepa10@gmail.com>
Sat, 15 Jul 2023 08:18:37 +0000 (11:18 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 15 Jul 2023 08:18:37 +0000 (11:18 +0300)
how valid the source is is entirely different thing, more than one
weather source can match a given location (look for "multiple" in the ions
and think why it is a thing)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kdeplasma-addons/libs/plasmaweather/weatherlocation.cpp

index e06d6f1..b2d68bd 100644 (file)
@@ -29,7 +29,8 @@ public:
     Private(WeatherLocation *location)
         : q(location),
           locationEngine(nullptr),
-          weatherEngine(nullptr)
+          weatherEngine(nullptr),
+          foundsource(false)
     {
     }
 
@@ -42,10 +43,11 @@ public:
         }
 
         validators.remove(validator);
-        if (!source.isEmpty()) {
+        if (!source.isEmpty() && !foundsource) {
+            foundsource = true;
             emit q->finished(source);
         }
-        if (validators.isEmpty()) {
+        if (!foundsource && validators.isEmpty()) {
             emit q->finished(QString());
         }
     }
@@ -53,6 +55,7 @@ public:
     WeatherLocation *q;
     Plasma::DataEngine *locationEngine;
     Plasma::DataEngine *weatherEngine;
+    bool foundsource;
     QMap<WeatherValidator*,QString> validators;
 };