OSDN Git Service

kdeplasma-addons: parent the weather validator to the weather location finder
authorIvailo Monev <xakepa10@gmail.com>
Sat, 15 Jul 2023 07:43:00 +0000 (10:43 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 15 Jul 2023 08:07:37 +0000 (11:07 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kdeplasma-addons/libs/plasmaweather/weatherlocation.cpp
kdeplasma-addons/libs/plasmaweather/weatherpopupapplet.cpp
kdeplasma-addons/libs/plasmaweather/weathervalidator.cpp
kdeplasma-addons/libs/plasmaweather/weathervalidator.h

index 5e093c1..e06d6f1 100644 (file)
@@ -28,7 +28,8 @@ class WeatherLocation::Private
 public:
     Private(WeatherLocation *location)
         : q(location),
-          locationEngine(nullptr)
+          locationEngine(nullptr),
+          weatherEngine(nullptr)
     {
     }
 
@@ -64,8 +65,7 @@ WeatherLocation::WeatherLocation(QObject *parent)
 
 WeatherLocation::~WeatherLocation()
 {
-    qDeleteAll(d->validators.keys());
-    d->validators.clear();
+    Q_ASSERT(d->validators.size() == 0);
     delete d;
 }
 
@@ -98,7 +98,7 @@ void WeatherLocation::dataUpdated(const QString &source, const Plasma::DataEngin
             city.truncate(city.indexOf(QLatin1Char(',')) - 1);
         }
         if (!city.isEmpty()) {
-            WeatherValidator* validator = new WeatherValidator();
+            WeatherValidator* validator = new WeatherValidator(this);
             validator->setDataEngine(d->weatherEngine);
             connect(
                 validator, SIGNAL(finished(QMap<QString,QString>)),
index 768cf63..05298d2 100644 (file)
@@ -81,9 +81,9 @@ public:
             q->setBusy(false);
             q->showMessage(QIcon(), QString(), Plasma::ButtonNone);
             q->setConfigurationRequired(true);
-            location->deleteLater();
-            location = 0;
         }
+        delete location;
+        location = 0;
     }
 
     void giveUpBeingBusy()
index da84abb..c5d15eb 100644 (file)
@@ -26,7 +26,7 @@ class WeatherValidator::Private
 {
 public:
     Private()
-        : dataengine(0),
+        : dataengine(nullptr),
           ion(QLatin1String( "wettercom" ))
     {}
 
@@ -36,7 +36,7 @@ public:
     bool silent;
 };
 
-WeatherValidator::WeatherValidator(QWidget *parent)
+WeatherValidator::WeatherValidator(QObject *parent)
     : QObject(parent)
     , d(new Private())
 {
index eb33558..4198a2d 100644 (file)
@@ -33,7 +33,7 @@ class PLASMAWEATHER_EXPORT WeatherValidator : public QObject
 {
     Q_OBJECT
 public:
-    WeatherValidator(QWidget *parent = 0);
+    WeatherValidator(QObject *parent = 0);
     virtual ~WeatherValidator();
 
     /**