fix memory leak
authorChristian Pulvermacher <christian@christian-laptop.(none)>
Wed, 13 Oct 2010 14:01:46 +0000 (16:01 +0200)
committerChristian Pulvermacher <christian@christian-laptop.(none)>
Wed, 13 Oct 2010 14:01:46 +0000 (16:01 +0200)
src/connectdialog.cpp

index 9d21ad6..5019bd1 100644 (file)
@@ -84,6 +84,9 @@ ConnectDialog::ConnectDialog(QWidget *parent):
        layout.addWidget(done);
 
        setLayout(&layout);
+
+       connect(this, SIGNAL(finished(int)),
+               this, SLOT(deleteLater()));
 }
 
 void ConnectDialog::indexChanged(int index) {
@@ -120,12 +123,10 @@ void ConnectDialog::accept()
 
        QString selected_host = hosts.currentText();
        if(selected_host.isEmpty()) {
-               deleteLater();
                return;
        }
        if(!hosts.itemIcon(hosts.currentIndex()).isNull()) {
                emit connectToHost("", 2, 5900); //TODO: quality and port from user input
-               deleteLater();
                return;
        }
 
@@ -159,5 +160,4 @@ void ConnectDialog::accept()
        settings.sync();
 
        emit connectToHost(QString("vnc://%1").arg(selected_host), quality, 0);
-       deleteLater();
 }