Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 258120 Details for
Bug 482162
[backports] Eclipse crashes with NPE on existing workspace (after closing window twice)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch482162_R4_2_maintenance.txt
patch482162_R4_2_maintenance.txt (text/plain), 8.15 KB, created by
Markus Keller
on 2015-11-18 08:08:03 EST
(
hide
)
Description:
patch482162_R4_2_maintenance.txt
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2015-11-18 08:08:03 EST
Size:
8.15 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java >index c344cc7..62a4282 100644 >--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java >+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Terry Parker <tparker@google.com> - Bug 416673 > ******************************************************************************/ > > package org.eclipse.e4.ui.internal.workbench.swt; >@@ -167,10 +168,19 @@ public class E4Application implements IApplication { > > public void saveModel() { > try { >- handler.save(); >+ if (!(handler instanceof ResourceHandler) >+ || ((ResourceHandler) handler).hasTopLevelWindows()) { >+ handler.save(); >+ } else { >+ Logger logger = new WorkbenchLogger(PLUGIN_ID); >+ logger.error( >+ new Exception(), // log a stack trace for debugging >+ "Attempted to save a workbench model that had no top-level windows! " //$NON-NLS-1$ >+ + "Skipped saving the model to avoid corruption."); //$NON-NLS-1$ >+ } > } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ Logger logger = new WorkbenchLogger(PLUGIN_ID); >+ logger.error(e, "Error saving the workbench model"); //$NON-NLS-1$ > } > } > >diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java >index cb95773..1105858 100644 >--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java >+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2012 IBM Corporation and others. >+ * Copyright (c) 2009, 2014 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Terry Parker <tparker@google.com> - Bug 416673 > ******************************************************************************/ > > package org.eclipse.e4.ui.internal.workbench; >@@ -121,6 +122,26 @@ public class ResourceHandler implements IModelResourceHandler { > > } > >+ /** >+ * @return {@code true} if the current application model has top-level windows. >+ */ >+ public boolean hasTopLevelWindows() { >+ return hasTopLevelWindows(resource); >+ } >+ >+ /** >+ * @return {@code true} if the specified application model has top-level windows. >+ */ >+ private boolean hasTopLevelWindows(Resource applicationResource) { >+ if (applicationResource == null || applicationResource.getContents() == null) { >+ // If the application resource doesn't exist or has no contents, then it has no >+ // top-level windows (and we are in an error state). >+ return false; >+ } >+ MApplication application = (MApplication) applicationResource.getContents().get(0); >+ return !application.getChildren().isEmpty(); >+ } >+ > public Resource loadMostRecentModel() { > File baseLocation; > try { >@@ -173,8 +194,12 @@ public class ResourceHandler implements IModelResourceHandler { > logger.error(e); > } > } >- if (appElement != null) >+ if (appElement != null) { > resource.getContents().add((EObject) appElement); >+ if (!hasTopLevelWindows(resource) && logger != null) { >+ logger.error("No top-level windows seen when migrating from existing delta files"); //$NON-NLS-1$ >+ } >+ } > return resource; > } > } >@@ -200,6 +225,15 @@ public class ResourceHandler implements IModelResourceHandler { > resource = null; > if (restore && saveAndRestore) { > resource = loadResource(restoreLocation); >+ // If the saved model does not have any top-level windows, Eclipse will exit >+ // immediately, so throw out the persisted state and reinitialize with the defaults. >+ if (!hasTopLevelWindows(resource)) { >+ if (logger != null) { >+ logger.error(new Exception(), // log a stack trace to help debug the corruption >+ "The persisted workbench has no top-level windows, so reinitializing with defaults."); //$NON-NLS-1$ >+ } >+ resource = null; >+ } > } > if (resource == null) { > Resource applicationResource = loadResource(applicationDefinitionInstance); >@@ -220,6 +254,13 @@ public class ResourceHandler implements IModelResourceHandler { > context); > contribProcessor.processModel(); > >+ if (!hasTopLevelWindows(resource) && logger != null) { >+ logger.error(new Exception(), // log a stack trace to help debug the >+ // corruption >+ "Initializing from the application definition instance yields no top-level windows! " //$NON-NLS-1$ >+ + "Continuing execution, but the missing windows may cause other initialization failures."); //$NON-NLS-1$ >+ } >+ > return resource; > } > >diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java >index 76495cf..a2339b2 100644 >--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java >+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java >@@ -1732,6 +1732,23 @@ UIEvents.Context.TOPIC_CONTEXT, > } > }); > >+ eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() { >+ public void handleEvent(org.osgi.service.event.Event event) { >+ Object element = event.getProperty(UIEvents.EventTags.ELEMENT); >+ if (!(element instanceof MApplication)) { >+ return; >+ } >+ MApplication app = (MApplication) element; >+ if (UIEvents.isREMOVE(event)) { >+ if (app.getChildren().isEmpty()) { >+ Object oldValue = event.getProperty(UIEvents.EventTags.OLD_VALUE); >+ WorkbenchPlugin.log("The final top level window " + oldValue //$NON-NLS-1$ >+ + " was just removed", new Exception()); //$NON-NLS-1$ >+ } >+ } >+ } >+ }); >+ > boolean found = false; > List<MPartDescriptor> currentDescriptors = application.getDescriptors(); > for (MPartDescriptor desc : currentDescriptors) { >diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java >index 5021df1..0c80205 100644 >--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java >+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java >@@ -1203,8 +1203,33 @@ public class WorkbenchWindow implements IWorkbenchWindow { > * Assumes that busy cursor is active. > */ > private boolean busyClose(boolean remove) { >- if (closing) >+ /* >+ * Warning: Intricate flow of control and re-entrant invocations of this >+ * method: >+ * >+ * - busyClose(true) is called from WorkbenchWindow#close() when the >+ * user closes a workbench window. >+ * >+ * - busyClose(false) is called from Workbench#close(int, boolean). This >+ * happens on File > Exit/Restart, [Mac] Quit Eclipse, AND ... tadaa ... >+ * from busyClose(true) when the user closes the last window => [Case A] >+ * >+ * Additional complication: busyClose(true) can also be called again >+ * when someone runs an event loop during the shutdown sequence. In that >+ * case, the nested busyClose(true) should be dropped (bug 381555) => >+ * [Case B] >+ */ >+ if (closing) { >+ // [Case A] Window is already closing. >+ return false; >+ } >+ if (updateDisabled && remove) { >+ // [Case B] User closed this window, which triggered >+ // "workbench.close()", during which the user tried to close this >+ // window again. > return false; >+ } >+ > // Whether the window was actually closed or not > boolean windowClosed = false; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review+
Actions:
View
|
Diff
Attachments on
bug 482162
: 258120