Skip to content

Commit

Permalink
Merge pull request #1575 from Mailaender/treeviewer-image-crash
Browse files Browse the repository at this point in the history
Fixed a native crash on Linux when opening the file browser tree for the first time
  • Loading branch information
eselmeister authored Dec 1, 2023
2 parents 5520f2d + 3aa9823 commit d29d04a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.eclipse.chemclipse.processing.converter.ISupplier;
import org.eclipse.chemclipse.processing.converter.ISupplierFileIdentifier;
import org.eclipse.chemclipse.support.ui.workbench.DisplayUtils;
import org.eclipse.chemclipse.ux.extension.ui.Activator;
import org.eclipse.chemclipse.ux.extension.ui.l10n.Messages;
import org.eclipse.chemclipse.ux.extension.ui.listener.DataExplorerDragListener;
Expand Down Expand Up @@ -153,7 +154,8 @@ private TreeViewer createTreeViewer(Composite parent, Function<File, Map<ISuppli

private void setInput(TreeViewer treeViewer) {

treeViewer.setInput(dataExplorerTreeRoot.getRootContent());
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=573090
DisplayUtils.getDisplay().asyncExec(() -> treeViewer.setInput(dataExplorerTreeRoot.getRootContent()));
}

private int getNumberOfChildDirectories(File directory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import javax.inject.Inject;

import org.eclipse.chemclipse.processing.converter.ISupplierFileIdentifier;
import org.eclipse.chemclipse.support.ui.workbench.DisplayUtils;
import org.eclipse.chemclipse.ux.extension.xxd.ui.Activator;
import org.eclipse.chemclipse.ux.extension.xxd.ui.swt.DataExplorerUI;
import org.eclipse.e4.core.contexts.IEclipseContext;
Expand All @@ -37,12 +36,7 @@ public class DataExplorerPart {
@PostConstruct
public void init(Composite parent, MPart part, IEclipseContext context) {

// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=573090
DisplayUtils.getDisplay().asyncExec(() -> {
dataExplorerUI = new DataExplorerUI(parent, preferenceStore, context, supplierFileIdentifier);
dataExplorerUI.getControl().redraw();
dataExplorerUI.getControl().requestLayout();
});
dataExplorerUI = new DataExplorerUI(parent, preferenceStore, context, supplierFileIdentifier);
}

public DataExplorerUI getDataExplorerUI() {
Expand All @@ -53,8 +47,6 @@ public DataExplorerUI getDataExplorerUI() {
@Focus
public void focus() {

if(dataExplorerUI != null) {
dataExplorerUI.setFocus();
}
dataExplorerUI.setFocus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ public void widgetDisposed(DisposeEvent e) {
@Override
public String getText(Object element) {

if(element instanceof File) {
return getName((File)element);
if(element instanceof File file) {
return getName(file);
}
return "-";
}
Expand All @@ -314,8 +314,8 @@ public Image getImage(Object element) {
@Override
public String getText(Object element) {

if(element instanceof File) {
return getPath((File)element);
if(element instanceof File file) {
return getPath(file);
}
return "-";
}
Expand Down

0 comments on commit d29d04a

Please sign in to comment.