Skip to content

Conversation

Theo-Dann-Muirhead-Renesas
Copy link
Contributor

ImageSet() fix for GTK4. #2299
Previously ImageSet() returned null on GTK4, This is an implementation of ImageSet() for GTK4.

To test:

  • Ensure GTK4 is forced with "SWT_GTK4 = 1" environment variable in ControlExample.
  • Start ControlExample -> Click "Menu" -> Check "Images" -> Click "Create Shell"

If Cascade dropdown has icons then the change is working.

image

Copy link
Contributor

github-actions bot commented Sep 26, 2025

Test Results

  118 files  ±0    118 suites  ±0   12m 25s ⏱️ + 1m 18s
4 583 tests ±0  4 547 ✅ ±0  36 💤 ±0  0 ❌ ±0 
  330 runs  ±0    307 ✅ ±0  23 💤 ±0  0 ❌ ±0 

Results for commit 803a4bb. ± Comparison against base commit 48e5878.

♻️ This comment has been updated with latest results.

@jonahgraham
Copy link
Contributor

@Theo-Dann-Muirhead-Renesas It looks like some part of your commit may be missing as build fails with:

Error: The method gtk_reorder_child_after(long, long, int) is undefined for the type GTK4

Did you have a change to GTK4.java that should be included here?

@jonahgraham
Copy link
Contributor

The full error is here, quoted below:

Error:  Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:5.0.0:compile (default-compile) on project org.eclipse.swt.gtk.linux.ppc64le: Compilation failure: Compilation failure: 
Error:  /home/runner/work/eclipse.platform.swt/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java:[1065] 
Error:  	GTK4.gtk_reorder_child_after(boxHandle, imageHandle, 0);
Error:  	     ^^^^^^^^^^^^^^^^^^^^^^^
Error:  The method gtk_reorder_child_after(long, long, int) is undefined for the type GTK4
Error:  /home/runner/work/eclipse.platform.swt/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java:[1095] 
Error:  	GTK4.gtk_box_remove(boxHandle, imageHandle);
Error:  	     ^^^^^^^^^^^^^^
Error:  The method gtk_box_remove(long, long) is undefined for the type GTK4
Error:  /home/runner/work/eclipse.platform.swt/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java:[1103] 
Error:  	GTK4.gtk_box_remove(boxHandle, imageHandle);
Error:  	     ^^^^^^^^^^^^^^
Error:  The method gtk_box_remove(long, long) is undefined for the type GTK4
Error: [ERROR] 5 problems (3 errors, 2 warnings)
Error:  -> [Help 1]

@Theo-Dann-Muirhead-Renesas
Copy link
Contributor Author

Yes, I missed that two methods were not originally included

@akurtakov
Copy link
Member

Please resolve the conflicts with master.

@akurtakov
Copy link
Member

As you can see by the failing check - merge commits are not welcome, so please rebase on master without merge commits.

} else {
if (imageHandle == 0) {
GTK4.gtk_image_set_from_paintable(imageHandle, surface);
if (imageHandle == 0) error(SWT.ERROR_NO_HANDLES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a crash here:
(SWT:623314): Gtk-CRITICAL **: 18:01:06.474: gtk_image_set_from_paintable: assertion 'GTK_IS_IMAGE (image)' failed
Exception in thread "main" org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:4980)
at org.eclipse.swt.SWT.error(SWT.java:4865)
at org.eclipse.swt.SWT.error(SWT.java:4836)
at org.eclipse.swt.widgets.Widget.error(Widget.java:598)
at org.eclipse.swt.widgets.MenuItem._setImage(MenuItem.java:1062)
at org.eclipse.swt.widgets.MenuItem._setEnabledOrDisabledImage(MenuItem.java:990)
at org.eclipse.swt.widgets.MenuItem.setImage(MenuItem.java:1037)
at org.eclipse.swt.examples.controlexample.MenuTab.createButtonSelected(MenuTab.java:97)
at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:83)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:286)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5884)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1656)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5099)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4540)
at org.eclipse.swt.examples.controlexample.ControlExample.main(ControlExample.java:240)

As imageHandle is 0 (checked on line 1060) you clearly can't set it but have to create it first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a crash here: (SWT:623314): Gtk-CRITICAL **: 18:01:06.474: gtk_image_set_from_paintable: assertion 'GTK_IS_IMAGE (image)' failed Exception in thread "main" org.eclipse.swt.SWTError: No more handles at org.eclipse.swt.SWT.error(SWT.java:4980) at org.eclipse.swt.SWT.error(SWT.java:4865) at org.eclipse.swt.SWT.error(SWT.java:4836) at org.eclipse.swt.widgets.Widget.error(Widget.java:598) at org.eclipse.swt.widgets.MenuItem._setImage(MenuItem.java:1062) at org.eclipse.swt.widgets.MenuItem._setEnabledOrDisabledImage(MenuItem.java:990) at org.eclipse.swt.widgets.MenuItem.setImage(MenuItem.java:1037) at org.eclipse.swt.examples.controlexample.MenuTab.createButtonSelected(MenuTab.java:97) at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:83) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:286) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5884) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1656) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5099) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4540) at org.eclipse.swt.examples.controlexample.ControlExample.main(ControlExample.java:240)

As imageHandle is 0 (checked on line 1060) you clearly can't set it but have to create it first.

I am still seeing this error..
I took the latest commit of this PR..

@akurtakov akurtakov changed the title MenuItem.ImageSet() GTK4 fix. MenuItem.setImage() GTK4 fix. Sep 26, 2025
@akurtakov
Copy link
Member

I guess all the ImageSet() in the commit message should really be setImage(), right ?

@akurtakov
Copy link
Member

There are conflicts with master, please always rebase on master before pushing new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants