FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: lazy initialize ImageRegistry by trancexpress · Pull Request #1011 · eclipse-tm4e/tm4e · GitHub

fix: lazy initialize ImageRegistry - #1011

Merged
sebthom merged 1 commit into
eclipse-tm4e:mainfrom
trancexpress:gh1010
Jul 2, 2026
Merged

fix: lazy initialize ImageRegistry#1011
sebthom merged 1 commit into
eclipse-tm4e:mainfrom
trancexpress:gh1010

Conversation

trancexpress commented Jun 11, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

This change adjusts TMUIPlugin.start() to not initialize the ImageRegistry, avoiding start-up exceptions when TMUIPlugin.start() is not called from a UI thread.

Instead, the ImageRegistry is initialized lazily by overriding: AbstractUIPlugin.initializeImageRegistry()

Fixes: #1010

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR updates TMUIPlugin.start() to avoid SWTError: Invalid thread access by deferring image-registry initialization to the UI thread when the Eclipse workbench is running (addressing issue #1010 seen in headless/LSP test scenarios).

Changes:

  • Replace direct image initialization in TMUIPlugin.start() with a dedicated initializeImages() helper.
  • Schedule TMImages initialization via an Eclipse UIJob when PlatformUI.isWorkbenchRunning() is true.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

sebthom commented Jun 12, 2026

Copy link
Copy Markdown
Member

@akurtakov do you think a more idomatic solution would be to not initialize the image registry in the start method or async via UIJob but lazy like this?

 @Override
 protected void initializeImageRegistry(final ImageRegistry registry) {
      TMImages.initalize(registry);
  }

sebthom commented Jun 30, 2026

Copy link
Copy Markdown
Member

@akurtakov ping :-)

Copy link
Copy Markdown
Contributor

@sebthom Sorry, this one got lost in the amount of notifications.
Your suggestion should be the way to go IMO, that should solve the problem as createImageRegistry already falls back to Display.getCurrent if platform is not running https://github.com/eclipse-platform/eclipse.platform.ui/blob/a217bfc2419673f6547fb67f0970cbf91bdf2192/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/plugin/AbstractUIPlugin.java#L160 .

This change adjusts TMUIPlugin.start() to not initialize the ImageRegistry,
avoiding start-up exceptions when TMUIPlugin.start() is not called from a UI thread.

Instead, the ImageRegistry is initialized lazily by overriding:
AbstractUIPlugin.initializeImageRegistry()

Fixes: eclipse-tm4e#1010
trancexpress changed the title fix: initialize images in a UI job if workbench is running fix: lazy initialize ImageRegistry Jul 1, 2026
sebthom merged commit 6314a5e into eclipse-tm4e:main Jul 2, 2026
23 checks passed

sebthom commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thanks!

Copy link
Copy Markdown
Contributor Author

Thank you for merging!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TMUIPlugin.start() throws SWTError when not called from UI thread

6 participants


Back | FazBrowse Home | New Git URL