> This PR fixes a Warning I always get when JavaFX and Swing are both mixed 
> together in an application.
> The error: `XSetErrorHandler() called with a GDK error trap pushed. Don't do 
> that.`
> 
> I attached a small reproducer to the ticket. It shows the sequence that must 
> happen for this error to appear:
> 
> 1. JavaFX will call `gdk_error_trap_push` 
> 2. Swing will call `XSetErrorHandler`
> 3. GDK will detect that the error handler is different from the one we pushed
> 
> See also:
> - 
> https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/x11/gdkmain-x11.c#L313
> 
> ---
> 
> Checking the Swing code, we just call `XSetErrorHandler` and not 
> `gdk_error_trap_push`. See also:
> 
> - [Swing 
> XlibWrapper](https://github.com/openjdk/jdk/blob/master/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c#L1328)
> - [Swing 
> gtk3_interface](https://github.com/openjdk/jdk/blob/master/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c#L679)
> 
> `gdk_error_trap_push` will call `XSetErrorHandler`, so we might as well do 
> that directly.
> I checked the code in `gdk_error_trap_push`, I do not see any problems with 
> this approach.
> 
> From what I understand, `gdk_error_trap_push` is meant to be short-lived, so 
> should be popped soon with `_gdk_error_handler_pop`. `XSetErrorHandler` makes 
> more sense as a 'long-lived' option, and it does the same for our usecase, 
> that is to not make the application exit on any `gdk_x_error`.
> 
> cc @tsayao, a review is appreciated.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Marius Hanl has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains two additional commits since the 
last revision:

 - Merge branch 'master' of https://github.com/openjdk/jfx into 
8156779-GTK3-warning-when-running-SwingNode-applications
 - 8156779: GTK3: warning when running SwingNode applications

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/2296/files
  - new: https://git.openjdk.org/jfx/pull/2296/files/4f98a472..9a272d4c

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=2296&range=01
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=2296&range=00-01

  Stats: 33355 lines in 504 files changed: 21636 ins; 7566 del; 4153 mod
  Patch: https://git.openjdk.org/jfx/pull/2296.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/2296/head:pull/2296

PR: https://git.openjdk.org/jfx/pull/2296

Reply via email to