Skip to content

[Win32] Encapsulate ToolItem's access to tool bar image lists - #3504

Open
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:toolbar-imagelists-cleanup-step1
Open

[Win32] Encapsulate ToolItem's access to tool bar image lists#3504
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:toolbar-imagelists-cleanup-step1

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

ToolItem manipulated ToolBar's three normal/hot/disabled ImageLists directly: reading them via ToolBar's getters, creating them inline when absent, and calling add()/put() on each of them itself. This spread the bookkeeping for a single item's images across both classes and made ToolItem responsible for details that are really ToolBar's to own, such as lazily creating the image lists sized to the first image added.

With this change, ToolBar exposes addImage/putImage/clearImage instead, and ToolItem goes through these instead of touching ImageList directly. ToolBar's internal representation (three separate ImageList fields, and their existing
setImageList/setHotImageList/setDisabledImageList synchronization methods) is otherwise unchanged.

This is a behavior-preserving refactoring: the image lists are still created, filled and synchronized with the same values as before.

The disabledImageList != null guard in ToolItem.updateImages is dropped rather than moved: in that branch the item already has an image index, so all three image lists necessarily exist, as they are only ever created together in addImage and cleared together in destroyItem and releaseWidget.

Related to #3466

Note: This change is human-crafted and was only slightly revised and documented with the help of AI

This is the first of multiple incremental steps to enhance ImageList handling and consistency inside ToolBar. This is supposed to be merged for 2026-12 M1.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Test Results (win32)

   35 files  ±0     35 suites  ±0   6m 2s ⏱️ + 1m 24s
4 868 tests ±0  4 792 ✅ ±0  76 💤 ±0  0 ❌ ±0 
1 395 runs  ±0  1 371 ✅ ±0  24 💤 ±0  0 ❌ ±0 

Results for commit be9c38f. ± Comparison against base commit 9ca368d.

♻️ This comment has been updated with latest results.

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.

Pull request overview

Encapsulates Win32 ToolBar image-list bookkeeping within ToolBar.

Changes:

  • Adds centralized add, update, and clear operations.
  • Makes image-list fields private.
  • Routes ToolItem image handling through ToolBar.

Reviewed changes

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

File Description
ToolItem.java Delegates image-list operations to its parent toolbar.
ToolBar.java Owns image-list mutation and lazy initialization.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java Outdated
ToolItem manipulated ToolBar's three normal/hot/disabled ImageLists
directly: reading them via ToolBar's getters, creating them inline
when absent, and calling add()/put() on each of them itself. This
spread the bookkeeping for a single item's images across both
classes and made ToolItem responsible for details that are really
ToolBar's to own, such as lazily creating the image lists sized to
the first image added.

With this change, ToolBar exposes addImage/putImage/clearImage
instead, and ToolItem goes through these instead of touching
ImageList directly. ToolBar's internal representation (three
separate ImageList fields, and their existing
setImageList/setHotImageList/setDisabledImageList synchronization
methods) is otherwise unchanged.

This is a behavior-preserving refactoring: the image lists are still
created, filled and synchronized with the same values as before.

The disabledImageList != null guard in ToolItem.updateImages is
dropped rather than moved: in that branch the item already has an
image index, so all three image lists necessarily exist, as they are
only ever created together in addImage and cleared together in
destroyItem and releaseWidget.

Related to
eclipse-platform#3466
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.

2 participants