Skip to content

Commit e3d540c

Browse files
committed
[GTK3] Do not crash in SetData event
The crash happens when renderers are replaced during render. If replacement is postponed, the crash no longer happens. Fixes #678.
1 parent e6588c2 commit e3d540c

File tree

1 file changed

+11
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+11
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,17 @@ public void setImage(int index, Image image) {
15561556
* supposed to be rendered in. See bug 513761.
15571557
*/
15581558
boolean check = modelIndex == Tree.FIRST_COLUMN && (parent.style & SWT.CHECK) != 0;
1559-
parent.createRenderers(column, modelIndex, check, parent.style);
1559+
// Renderers can't be replaced during render on GTK 3.24.41
1560+
// https://github.com/eclipse-platform/eclipse.platform.swt/issues/678
1561+
getDisplay().asyncExec(() -> {
1562+
// Do not perform request when it is no longer applicable
1563+
if (parent.isDisposed() || parent.columns.length <= index) return;
1564+
// On multiple resize requests, perform only the last one
1565+
if (parent.pixbufHeight != iHeight || parent.pixbufWidth != iWidth) return;
1566+
int modelIndexAsync = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
1567+
long columnAsync = GTK.gtk_tree_view_get_column (parent.handle, index);
1568+
parent.createRenderers(columnAsync, modelIndexAsync, check, parent.style);
1569+
});
15601570
}
15611571
}
15621572
}

0 commit comments

Comments
 (0)