forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Orgad Shaneh
parent
838ce020a8
commit
df767f1c48
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user