Skip to content

GUI: Refactor: Show modal JavaWindows without blocking Matlab thread - #939

Draft
rcassani wants to merge 2 commits into
brainstorm-tools:masterfrom
rcassani:refactor-modal-jcontainers
Draft

GUI: Refactor: Show modal JavaWindows without blocking Matlab thread#939
rcassani wants to merge 2 commits into
brainstorm-tools:masterfrom
rcassani:refactor-modal-jcontainers

Conversation

@rcassani

Copy link
Copy Markdown
Member

This PR changes the call to awtinvoke to java_call (which preferentially uses javaMethodEDT).

The change has as goal to remove the reliance in awtinvoke as per the following warning (introduced in R2026a, and reported by @jeanborn and @Edouard2laire).

Warning: 'awtinvoke' is unsupported and might have been changed or removed without notice. With appropriate code changes, use javaMethodEDT instead.

In the current (before this PR code), calling awtinvoke does not block the Matlab thread even when the JavaWindow is modal, so all the Matlab code continue. In the case of modal windows there are two approaches:

  1. The panel gives the impression that the Matlab thread is blocked, as the Matlab code after creating the modal window just do minor changes in the panel (no further commands) e.g. panel_protocol_editor. So, only the callbacks of the panel remained to be executed.

  2. Where a real block of the Matlab thread is needed, the function bst_mutex() is used in the creation of the panel. And the [OK] button callback releases this mutex.

Now, by changing awtinvoke to java_call there is a block of the Matlab thread when the modal JavaWindow is shown. So there is the need of refactor in both cases of modal windows:

  1. In this case, just perform all the panel modifications and set its callbacks before showing the modal JavaWindow(Commit 9edd66a). Only the callbacks of the panel need to be executed.

  2. Panels with bst_mutex, e.g. panel_timefreq_options. Here, the Matlab thread is blocked by the modal window, thus its [OK] button callback does not work (it just releases the mutex). Ideally, when this panels are called, in modal mode, there is no need of the mutex, as the block will come from java_call.

- Shown modal `JavaWindows` after adding them to the Global panel list
- Update values and title for `panel_subject_editor` before `gui_show`
- Update preferred size of `panel_protocol_editor` before `gui_show`
rcassani referenced this pull request Aug 19, 2026
- Shown modal `JavaWindows` after adding them to the Global panel list
- Update values and title for `panel_subject_editor` before `gui_show`
- Update preferred size of `panel_protocol_editor` before `gui_show`
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.

1 participant