Fix a crash by clearing our reference to the menuwidget when it is deleted
authorRoy Marples <roy@marples.name>
Wed, 3 Dec 2014 13:38:00 +0000 (13:38 +0000)
committerRoy Marples <roy@marples.name>
Wed, 3 Dec 2014 13:38:00 +0000 (13:38 +0000)
by QWidgetAction.

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

index b1995d90744c56df7dafdb27f8bbcee666cbfb50..459301a8559584cb39f5370d3c637f2290bff64b 100644 (file)
@@ -49,12 +49,22 @@ DhcpcdSsidMenu::DhcpcdSsidMenu(QWidget *parent,
 
 QWidget *DhcpcdSsidMenu::createWidget(QWidget *parent)
 {
+
        ssidWidget = new DhcpcdSsidMenuWidget(parent, wi, scan);
        connect(ssidWidget, SIGNAL(hovered()), this, SLOT(hover()));
        connect(ssidWidget, SIGNAL(triggered()), this, SLOT(trigger()));
        return ssidWidget;
 }
 
+void DhcpcdSsidMenu::deleteWidget(QWidget *widget)
+{
+
+       widget->hide();
+       widget->deleteLater();
+       if (ssidWidget == widget)
+               ssidWidget = NULL;
+}
+
 DHCPCD_WI_SCAN *DhcpcdSsidMenu::getScan()
 {
 
index 108409ca224910f097bf77e0286be7bffa9f5a69..a359c50459f9b6098007f16a12f12c4099c17ed2 100644 (file)
@@ -43,6 +43,7 @@ public:
        ~DhcpcdSsidMenu() {};
 
        QWidget *createWidget(QWidget *parent);
+       void deleteWidget(QWidget *widget);
        DHCPCD_WI_SCAN *getScan();
        void setScan(DHCPCD_WI_SCAN *scan);
        bool isAssociated();
index 16767c3f0874ea54f3456e921b2a613f8f47a239..060b2b30c104361a67930230ccb054d1079c339c 100644 (file)
@@ -95,7 +95,7 @@ bool DhcpcdWi::setScans(DHCPCD_WI_SCAN *scans)
 {
        bool changed = false;
 
-       if (menu && menu->isVisible()) {
+       if (menu) {
                QList<DhcpcdSsidMenu*> lst;
                DHCPCD_WI_SCAN *scan;
                DHCPCD_IF *i;