clang-tidy: Avoid memory leak in MainWin
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 5 Sep 2018 18:58:46 +0000 (20:58 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Sep 2018 06:02:07 +0000 (08:02 +0200)
This one is legitimate: If no network is selected, the freshly
created ChannelListDlg instance is never deleted. Move instantiation
after the network ID check, so the dialog is shown (and self-deletes
on close). Set a parent for good measure, too.

src/qtui/mainwin.cpp

index 3ada47f..d87026c 100644 (file)
@@ -1489,8 +1489,6 @@ void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantL
 
 void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately)
 {
 
 void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately)
 {
-    ChannelListDlg *channelListDlg = new ChannelListDlg();
-
     if (!netId.isValid()) {
         QAction *action = qobject_cast<QAction *>(sender());
         if (action)
     if (!netId.isValid()) {
         QAction *action = qobject_cast<QAction *>(sender());
         if (action)
@@ -1507,7 +1505,7 @@ void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bo
         }
     }
 
         }
     }
 
-
+    ChannelListDlg *channelListDlg = new ChannelListDlg(this);
     channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
     channelListDlg->setNetwork(netId);
     if (!channelFilters.isEmpty()) {
     channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
     channelListDlg->setNetwork(netId);
     if (!channelFilters.isEmpty()) {