diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2013-05-06 21:53:17 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2013-05-07 11:00:54 +0200 |
commit | df767f1c48a3e89fb55e37fa499bff291ae22804 (patch) | |
tree | 050f345fce90354bd1254c622922093665652ada /src/plugins/git/gerrit/gerritplugin.cpp | |
parent | 838ce020a8e6f6899c48f20411a0109a6cfb3b34 (diff) | |
download | qt-creator-df767f1c48a3e89fb55e37fa499bff291ae22804.tar.gz |
Git: Fix leak when GerritPushDialog is canceled or fails
Change-Id: Id7479f44ee01f68e1423cc8346bc80f78ddfedb4
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/git/gerrit/gerritplugin.cpp')
-rw-r--r-- | src/plugins/git/gerrit/gerritplugin.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 80f5f56d14..040df73272 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -363,7 +363,9 @@ void GerritPlugin::push() { const QString topLevel = Git::Internal::GitPlugin::instance()->currentState().topLevel(); - QPointer<GerritPushDialog> dialog = new GerritPushDialog(topLevel, Core::ICore::mainWindow()); + // QScopedPointer is required to delete the dialog when leaving the function + QScopedPointer<GerritPushDialog> dialog( + new GerritPushDialog(topLevel, Core::ICore::mainWindow())); if (!dialog->localChangesFound()) { QMessageBox::warning(Core::ICore::mainWindow(), tr("No Local Changes"), @@ -377,11 +379,15 @@ void GerritPlugin::push() return; } + // QPointer is required to detect dialog deletion while in exec() + QPointer<GerritPushDialog> dlg = dialog.data(); if (dialog->exec() == QDialog::Rejected) return; - if (dialog.isNull()) + if (dlg.isNull()) { + dialog.take(); return; + } QStringList args; @@ -406,8 +412,6 @@ void GerritPlugin::push() args << target; Git::Internal::GitPlugin::instance()->gitClient()->synchronousPush(topLevel, args); - - delete dialog; } // Open or raise the Gerrit dialog window. |