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 67421 Details for
Bug 173049
[ErrorHandling] multiple stacked "Internal error" dialogs after OutOfMemoryError
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]
Fix proposal 01
173049.txt (text/plain), 10.22 KB, created by
Szymon Brandys
on 2007-05-16 11:19:52 EDT
(
hide
)
Description:
Fix proposal 01
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2007-05-16 11:19:52 EDT
Size:
10.22 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java,v >retrieving revision 1.11 >diff -u -r1.11 IDEWorkbenchErrorHandler.java >--- src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java 21 Mar 2007 15:46:13 -0000 1.11 >+++ src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java 16 May 2007 15:19:05 -0000 >@@ -14,16 +14,19 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.osgi.util.NLS; >-import org.eclipse.swt.SWT; > import org.eclipse.swt.SWTError; >-import org.eclipse.swt.widgets.MessageBox; >+import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.application.IWorkbenchConfigurer; > import org.eclipse.ui.internal.ide.dialogs.InternalErrorDialog; >+import org.eclipse.ui.progress.IProgressConstants; > import org.eclipse.ui.progress.UIJob; > import org.eclipse.ui.statushandlers.StatusAdapter; >+import org.eclipse.ui.statushandlers.StatusManager; > import org.eclipse.ui.statushandlers.WorkbenchErrorHandler; > > import com.ibm.icu.text.MessageFormat; >@@ -40,9 +43,7 @@ > > private int exceptionCount = 0; > >- private InternalErrorDialog dialog; >- >- private Shell defaultParent; >+ static private FatalErrorDialog dialog; > > private boolean closing = false; > >@@ -62,7 +63,7 @@ > > private static String MSG_FATAL_ERROR_Recursive = IDEWorkbenchMessages.FatalError_RecursiveError; > >- private static String MSG_FATAL_ERROR_RecursiveTitle = IDEWorkbenchMessages.Internal_error; >+ private static String MSG_FATAL_ERROR_Title = IDEWorkbenchMessages.InternalError; > > /** > * @param configurer >@@ -78,7 +79,22 @@ > * int) > */ > public void handle(final StatusAdapter statusAdapter, int style) { >- if (statusAdapter.getStatus().getException() != null) { >+ >+ // if fatal error occurs, we will show the error dialog anyway >+ if (isFatal(statusAdapter)) { >+ if (statusAdapter >+ .getProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY) == Boolean.TRUE) { >+ statusAdapter.setProperty( >+ IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, >+ Boolean.FALSE); >+ } >+ super.handle(statusAdapter, StatusManager.BLOCK); >+ } else { >+ super.handle(statusAdapter, style); >+ } >+ >+ // if fatal error occurs, we will ask to close the workbench >+ if (isFatal(statusAdapter) && style != StatusManager.NONE) { > UIJob handlingExceptionJob = new UIJob("IDE Exception Handler") //$NON-NLS-1$ > { > /* >@@ -99,45 +115,26 @@ > handlingExceptionJob.setSystem(true); > handlingExceptionJob.schedule(); > } >- >- super.handle(statusAdapter, style); > } > >- private Shell getParentShell() { >- if (defaultParent == null) { >- defaultParent = new Shell(); >+ private boolean isFatal(final StatusAdapter statusAdapter) { >+ if (statusAdapter.getStatus().getException() != null >+ && (statusAdapter.getStatus().getException() instanceof OutOfMemoryError >+ || statusAdapter.getStatus().getException() instanceof StackOverflowError >+ || statusAdapter.getStatus().getException() instanceof VirtualMachineError || statusAdapter >+ .getStatus().getException() instanceof SWTError)) { >+ return true; > } >- >- return defaultParent; >+ return false; > } > >- /** >- * Handles an event loop exception >- * >- * @param t >- * the exception to handle >- */ >- public void handleException(Throwable t) { >+ private void handleException(Throwable t) { > try { > exceptionCount++; > if (exceptionCount > 1) { >- if (closing) { >- return; >- } >- Shell parent = getParentShell(); >- if (dialog != null && dialog.getShell() != null >- && !dialog.getShell().isDisposed()) { >- parent = dialog.getShell(); >- } >- MessageBox box = new MessageBox(parent, SWT.ICON_ERROR >- | SWT.YES | SWT.NO | SWT.SYSTEM_MODAL); >- box.setText(MSG_FATAL_ERROR_RecursiveTitle); >- box.setMessage(MessageFormat.format(MSG_FATAL_ERROR, >+ dialog.updateMessage(MessageFormat.format(MSG_FATAL_ERROR, > new Object[] { MSG_FATAL_ERROR_Recursive })); >- int result = box.open(); >- if (result == SWT.YES) { >- closeWorkbench(); >- } >+ dialog.getShell().forceActive(); > } else { > if (openQuestionDialog(t)) { > closeWorkbench(); >@@ -149,7 +146,81 @@ > } > > /** >- * Close the workbench and make sure all exceptions are handled. >+ * Informs the user about a fatal error. Returns true if the user decide to >+ * exit workbench or if another fatal error happens while reporting it. >+ */ >+ private boolean openQuestionDialog(Throwable t) { >+ try { >+ String msg = null; >+ if (t instanceof OutOfMemoryError) { >+ msg = MSG_OutOfMemoryError; >+ } else if (t instanceof StackOverflowError) { >+ msg = MSG_StackOverflowError; >+ } else if (t instanceof VirtualMachineError) { >+ msg = MSG_VirtualMachineError; >+ } else if (t instanceof SWTError) { >+ msg = MSG_SWTError; >+ } else { >+ if (t.getMessage() == null) { >+ msg = IDEWorkbenchMessages.InternalErrorNoArg; >+ } else { >+ msg = NLS.bind(IDEWorkbenchMessages.InternalErrorOneArg, t >+ .getMessage()); >+ } >+ } >+ >+ // Always open the dialog in case of major error but do not show the >+ // detail button if not in debug mode. >+ Throwable detail = t; >+ if (!Policy.DEBUG_OPEN_ERROR_DIALOG) { >+ detail = null; >+ } >+ >+ dialog = openInternalQuestionDialog(PlatformUI.getWorkbench() >+ .getActiveWorkbenchWindow().getShell(), >+ MSG_FATAL_ERROR_Title, MessageFormat.format( >+ MSG_FATAL_ERROR, new Object[] { msg }), detail, 1); >+ >+ return dialog.open() == 0; >+ } catch (Throwable th) { >+ // Workbench may be in such bad shape (no OS handles left, out of >+ // memory, etc) >+ // that is cannot show a message to the user. Just bail out now. >+ System.err >+ .println("Error while informing user about event loop exception:"); //$NON-NLS-1$ >+ t.printStackTrace(); >+ System.err.println("Dialog open exception:"); //$NON-NLS-1$ >+ th.printStackTrace(); >+ return true; >+ } >+ } >+ >+ private FatalErrorDialog openInternalQuestionDialog(Shell parent, >+ String title, String message, Throwable detail, int defaultIndex) { >+ String[] labels; >+ if (detail == null) { >+ labels = new String[] { IDialogConstants.YES_LABEL, >+ IDialogConstants.NO_LABEL }; >+ } else { >+ labels = new String[] { IDialogConstants.YES_LABEL, >+ IDialogConstants.NO_LABEL, >+ IDialogConstants.SHOW_DETAILS_LABEL }; >+ } >+ >+ FatalErrorDialog dialog = new FatalErrorDialog(parent, title, null, // accept >+ // the >+ // default >+ // window >+ // icon >+ message, detail, MessageDialog.QUESTION, labels, defaultIndex); >+ if (detail != null) { >+ dialog.setDetailButton(2); >+ } >+ return dialog; >+ } >+ >+ /** >+ * Closes the workbench and make sure all exceptions are handled. > */ > private void closeWorkbench() { > if (closing) { >@@ -182,55 +253,36 @@ > } > } > >- /** >- * Inform the user about a fatal error. Return true if the user decide to >- * exit workbench or if another fatal error happens while reporting it. >- */ >- private boolean openQuestionDialog(Throwable internalError) { >- try { >- String msg = null; >- if (internalError instanceof OutOfMemoryError) { >- msg = MSG_OutOfMemoryError; >- } else if (internalError instanceof StackOverflowError) { >- msg = MSG_StackOverflowError; >- } else if (internalError instanceof VirtualMachineError) { >- msg = MSG_VirtualMachineError; >- } else if (internalError instanceof SWTError) { >- msg = MSG_SWTError; >- } else { >- if (internalError.getMessage() == null) { >- msg = IDEWorkbenchMessages.InternalErrorNoArg; >- } else { >- msg = NLS.bind(IDEWorkbenchMessages.InternalErrorOneArg, >- internalError.getMessage()); >- } >- // if (Policy.DEBUG_OPEN_ERROR_DIALOG) { >- // return openQuestion(null, >- // IDEWorkbenchMessages.Internal_error, msg, >- // internalError, 1); >- // } >- return false; >- } >- // Always open the dialog in case of major error but do not show the >- // detail button if not in debug mode. >- Throwable detail = internalError; >- if (!Policy.DEBUG_OPEN_ERROR_DIALOG) { >- detail = null; >- } >- return InternalErrorDialog.openQuestion(PlatformUI.getWorkbench() >- .getActiveWorkbenchWindow().getShell(), >- IDEWorkbenchMessages.Internal_error, MessageFormat.format( >- MSG_FATAL_ERROR, new Object[] { msg }), detail, 1); >- } catch (Throwable th) { >- // Workbench may be in such bad shape (no OS handles left, out of >- // memory, etc) >- // that is cannot show a message to the user. Just bail out now. >- System.err >- .println("Error while informing user about event loop exception:"); //$NON-NLS-1$ >- internalError.printStackTrace(); >- System.err.println("Dialog open exception:"); //$NON-NLS-1$ >- th.printStackTrace(); >- return true; >+ private class FatalErrorDialog extends InternalErrorDialog { >+ >+ /** >+ * @param parentShell >+ * @param dialogTitle >+ * @param dialogTitleImage >+ * @param dialogMessage >+ * @param detail >+ * @param dialogImageType >+ * @param dialogButtonLabels >+ * @param defaultIndex >+ */ >+ public FatalErrorDialog(Shell parentShell, String dialogTitle, >+ Image dialogTitleImage, String dialogMessage, Throwable detail, >+ int dialogImageType, String[] dialogButtonLabels, >+ int defaultIndex) { >+ super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, >+ detail, dialogImageType, dialogButtonLabels, defaultIndex); >+ } >+ >+ /** >+ * Updates the dialog message >+ * >+ * @param message >+ * new message >+ */ >+ public void updateMessage(String message) { >+ this.message = message; >+ this.messageLabel.setText(message); >+ this.messageLabel.update(); > } > } > }
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
Actions:
View
|
Diff
Attachments on
bug 173049
:
58336
|
67421
|
67430
|
67462