Permalink
Browse files

STS-3081: added checks to avoid calling disposed widgets in running jobs

  • Loading branch information...
1 parent 1c2e8e2 commit 984e2a625a306a210e9e106ddfe642383028641e @martinlippert martinlippert committed Nov 27, 2012
@@ -992,7 +992,8 @@ private void displayFeeds(final Composite composite, final ScrolledComposite scr
public void done(IJobChangeEvent event) {
unfinishedJobs.remove(job);
IWorkbenchPartSite site = getSite();
- if (site != null) {
+ if (site != null && site.getShell() != null && !site.getShell().isDisposed()
+ && site.getShell().getDisplay() != null && !site.getShell().getDisplay().isDisposed()) {
site.getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
Map<SyndEntry, SyndFeed> entryToFeed = job.getFeedReader().getFeedsWithEntries();
@@ -1144,43 +1145,46 @@ private void displayUpdates(final Composite composite, final PageBook pagebook,
public void done(IJobChangeEvent event) {
unfinishedJobs.remove(job);
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getManagedForm().getForm().isDisposed()) {
- return;
- }
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ if (display != null && !display.isDisposed()) {
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (getManagedForm().getForm().isDisposed()) {
+ return;
+ }
- List<UpdateNotification> notifications = job.getNotifications();
- if (notifications.isEmpty()) {
- pagebook.showPage(disclaimer);
- return;
- }
+ List<UpdateNotification> notifications = job.getNotifications();
+ if (notifications.isEmpty()) {
+ pagebook.showPage(disclaimer);
+ return;
+ }
- // make sure the entries are sorted correctly
- Collections.sort(notifications, new Comparator<UpdateNotification>() {
- public int compare(UpdateNotification o1, UpdateNotification o2) {
- return o2.getEntry().getPublishedDate().compareTo(o1.getEntry().getPublishedDate());
+ // make sure the entries are sorted correctly
+ Collections.sort(notifications, new Comparator<UpdateNotification>() {
+ public int compare(UpdateNotification o1, UpdateNotification o2) {
+ return o2.getEntry().getPublishedDate().compareTo(o1.getEntry().getPublishedDate());
+ }
+ });
+
+ int counter = 0;
+ Control[] children = composite.getChildren();
+ for (UpdateNotification notification : notifications) {
+ displayUpdate(notification.getEntry(), notification.getSeverity(), composite, counter,
+ children);
+ counter++;
}
- });
-
- int counter = 0;
- Control[] children = composite.getChildren();
- for (UpdateNotification notification : notifications) {
- displayUpdate(notification.getEntry(), notification.getSeverity(), composite, counter,
- children);
- counter++;
- }
- for (int i = counter * 2; i < children.length; i++) {
- children[i].dispose();
- }
+ for (int i = counter * 2; i < children.length; i++) {
+ children[i].dispose();
+ }
- composite.changed(composite.getChildren());
- composite.pack(true);
- composite.redraw();
- composite.getParent().redraw();
- }
- });
+ composite.changed(composite.getChildren());
+ composite.pack(true);
+ composite.redraw();
+ composite.getParent().redraw();
+ }
+ });
+ }
}
});
unfinishedJobs.add(job);

0 comments on commit 984e2a6

Please sign in to comment.