From: Manuel Nickschas Date: Wed, 5 Sep 2018 18:58:46 +0000 (+0200) Subject: clang-tidy: Avoid memory leak in MainWin X-Git-Tag: 0.13-rc2~38 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=bfeb38f1572e44bdfbfb7f4d47d6dc6ecc20439f clang-tidy: Avoid memory leak in MainWin 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. --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 3ada47fd..d87026c3 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1489,8 +1489,6 @@ void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantL void MainWin::showChannelList(NetworkId netId, const QString &channelFilters, bool listImmediately) { - ChannelListDlg *channelListDlg = new ChannelListDlg(); - if (!netId.isValid()) { QAction *action = qobject_cast(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()) {