From 1ed1e8c52fdb8c49b5b50163521233a8202a8df6 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Fri, 12 Apr 2013 14:25:36 +0200 Subject: Don't access disposed widget in StashCreateUI.showNoChangesToStash() The method is called from the job and the original shell may not be there anymore in case of showing this from the branch checkout dialog. Bug: 389866 Change-Id: Idf7480a823fa84b684c00648a664ad3dac15cd70 --- .../egit/ui/internal/branch/BranchResultDialog.java | 4 ++-- .../repository/tree/command/StashCreateCommand.java | 4 ++-- .../eclipse/egit/ui/internal/stash/StashCreateUI.java | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'org.eclipse.egit.ui') diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchResultDialog.java index 4598c0b532..76a20fc81e 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchResultDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/branch/BranchResultDialog.java @@ -152,8 +152,8 @@ public class BranchResultDialog extends MessageDialog { shouldCheckout = true; break; case IDialogConstants.SKIP_ID: - StashCreateUI stashCreateUI = new StashCreateUI(getShell(), repository); - shouldCheckout = stashCreateUI.createStash(); + StashCreateUI stashCreateUI = new StashCreateUI(repository); + shouldCheckout = stashCreateUI.createStash(getShell()); break; case IDialogConstants.CANCEL_ID: super.buttonPressed(buttonId); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashCreateCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashCreateCommand.java index 1b34bebda7..7b760c16c2 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashCreateCommand.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/StashCreateCommand.java @@ -40,8 +40,8 @@ public class StashCreateCommand extends return null; final Shell shell = HandlerUtil.getActiveShell(event); - StashCreateUI stashCreateUI = new StashCreateUI(shell, repo); - stashCreateUI.createStash(); + StashCreateUI stashCreateUI = new StashCreateUI(repo); + stashCreateUI.createStash(shell); return null; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/stash/StashCreateUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/stash/StashCreateUI.java index 73c6c81b60..77e046e83e 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/stash/StashCreateUI.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/stash/StashCreateUI.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2012 GitHub Inc. + * Copyright (c) 2012, 2013 GitHub Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,28 +25,29 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.window.Window; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; /** * The UI wrapper for {@link StashCreateOperation} */ public class StashCreateUI { private Repository repo; - private Shell shell; /** - * @param shell * @param repo */ - public StashCreateUI(Shell shell, Repository repo) { - this.shell = shell; + public StashCreateUI(Repository repo) { this.repo = repo; } /** + * @param shell + * the shell to use for showing the message input dialog * @return true if a stash create operation was triggered */ - public boolean createStash() { + public boolean createStash(Shell shell) { InputDialog commitMessageDialog = new InputDialog(shell, UIText.StashCreateCommand_titleEnterCommitMessage, UIText.StashCreateCommand_messageEnterCommitMessage, @@ -89,10 +90,12 @@ public class StashCreateUI { } - private void showNoChangesToStash() { - shell.getDisplay().asyncExec(new Runnable() { + private static void showNoChangesToStash() { + Display.getDefault().asyncExec(new Runnable() { public void run() { + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); MessageDialog.openInformation(shell, UIText.StashCreateCommand_titleNoChanges, UIText.StashCreateCommand_messageNoChanges); -- cgit v1.2.3