We need to close dhcpcd-wi instances as deleteLater keeps some stuff active
authorRoy Marples <roy@marples.name>
Tue, 12 May 2015 22:04:26 +0000 (22:04 +0000)
committerRoy Marples <roy@marples.name>
Tue, 12 May 2015 22:04:26 +0000 (22:04 +0000)
when it really isn't.

src/dhcpcd-qt/dhcpcd-qt.cpp
src/dhcpcd-qt/dhcpcd-wi.cpp
src/dhcpcd-qt/dhcpcd-wi.h

index 45bfda3ee68b83f217d09b15e70080690e103793..178e7d877c6552050f1021ad6138b083ad979fb0 100644 (file)
@@ -399,6 +399,7 @@ void DhcpcdQt::scanCallback(DHCPCD_WPA *wpa)
                qCritical("No fd for WPA");
                if (wi) {
                        wis->removeOne(wi);
+                       wi->close();
                        wi->deleteLater();
                }
                return;
@@ -409,6 +410,7 @@ void DhcpcdQt::scanCallback(DHCPCD_WPA *wpa)
                qCritical("No interface for WPA");
                if (wi) {
                        wis->removeOne(wi);
+                       wi->close();
                        wi->deleteLater();
                }
                return;
@@ -421,8 +423,10 @@ void DhcpcdQt::scanCallback(DHCPCD_WPA *wpa)
                if (wi->open()) {
                        wis->append(wi);
                        wi->setScans(scans);
-               } else
+               } else {
+                       wi->close();
                        wi->deleteLater();
+               }
        } else
                processScans(wi, scans);
 
@@ -460,6 +464,7 @@ void DhcpcdQt::wpaStatusCallback(DHCPCD_WPA *wpa,
                DhcpcdWi *wi = findWi(wpa);
                if (wi) {
                        wis->removeOne(wi);
+                       wi->close();
                        wi->deleteLater();
                }
        }
index 13b512968d4d54f440fdbed7315e3015dda3e23c..aeec2826bd765e53cb920b0b2f7a09237c45035a 100644 (file)
@@ -60,39 +60,32 @@ DhcpcdWi::DhcpcdWi(DhcpcdQt *parent, DHCPCD_WPA *wpa)
 DhcpcdWi::~DhcpcdWi()
 {
 
+       close();
        if (menu) {
                dhcpcdQt->menuDeleted(menu);
-               menu->setVisible(false);
                menu->deleteLater();
                menu = NULL;
        }
 
        if (notifier) {
-               notifier->setEnabled(false);
                notifier->deleteLater();
                notifier = NULL;
        }
 
        if (pingTimer) {
-               pingTimer->stop();
                pingTimer->deleteLater();
                pingTimer = NULL;
        }
 
        if (ssid) {
-               ssid->reject();
                ssid->deleteLater();
                ssid = NULL;
        }
 
        if (scanTimer) {
-               scanTimer->stop();
                scanTimer->deleteLater();
                scanTimer = NULL;
        }
-
-       dhcpcd_wi_scans_free(scans);
-       dhcpcd_wpa_close(wpa);
 }
 
 DHCPCD_WPA *DhcpcdWi::getWpa()
@@ -258,6 +251,34 @@ bool DhcpcdWi::open()
        return true;
 }
 
+void DhcpcdWi::close()
+{
+
+       if (menu)
+               menu->setVisible(false);
+
+       if (notifier)
+               notifier->setEnabled(false);
+
+       if (pingTimer)
+               pingTimer->stop();
+
+       if (ssid)
+               ssid->reject();
+
+       if (scanTimer)
+               scanTimer->stop();
+
+       if (scans) {
+               dhcpcd_wi_scans_free(scans);
+               scans = NULL;
+       }
+       if (wpa) {
+               dhcpcd_wpa_close(wpa);
+               wpa = NULL;
+       }
+}
+
 void DhcpcdWi::dispatch()
 {
 
index d4a65c10d3055e7c56fafd8f329987cb8a180aa5..e5d4aa9b0f620e8f81b63ea14d61b4cc7f8cacb5 100644 (file)
@@ -50,6 +50,7 @@ public:
        ~DhcpcdWi();
        DHCPCD_WPA *getWpa();
        bool open();
+       void close();
 
        DHCPCD_WI_SCAN *getScans();
        bool setScans(DHCPCD_WI_SCAN *scans);