Skip to content

Commit

Permalink
#749 - PCA perspective freezes on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Sep 28, 2021
1 parent 614d5df commit d15c2e0
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2020 Lablicate GmbH.
* Copyright (c) 2013, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -20,8 +20,11 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
Expand All @@ -32,6 +35,7 @@

public class ApplicationImage implements IApplicationImage, BundleTrackerCustomizer<IconBundle> {

private static final Logger logger = Logger.getLogger(ApplicationImage.class);
private static final String BUNDLE_SEPARATOR = "/";
//
private final BundleTracker<IconBundle> bundleTracker;
Expand Down Expand Up @@ -62,12 +66,21 @@ public Image getImage(String fileName, String size, boolean active) {
//
Image image = getProvider(parts[0]).getImage(parts[1], size, active);
if(active) {
imageDecorator.setSize(size);
imageDecorator.setImage(image);
return imageDecorator.createImage();
} else {
return image;
/*
* Sometimes, a TimeOutException occurs.
* This could happen if a decorated image is requested
* but somehow the widget isn't visible.
*/
try {
imageDecorator.setSize(size);
imageDecorator.setImage(image);
image = CompletableFuture.supplyAsync(() -> imageDecorator.createImage()).get(20, TimeUnit.MILLISECONDS);

This comment has been minimized.

Copy link
@Mailaender

Mailaender Sep 28, 2021

Contributor

I like #750 a little better, as it does not rely on a fixed timeout. What if it takes longer on a slower machine.

} catch(Exception e) {
logger.warn(e);
}
}
//
return image;
});
}

Expand Down

0 comments on commit d15c2e0

Please sign in to comment.