Skip to content

Conversation

@kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 17, 2025

Identify the Bug or Feature request

Fixes #5865

Description of the Change

Removes the ButtonKind.INSTALL listener from AddResourceDialog since its GenericDialog will automatically call commit() for us when the dialog is approvingly closed. Doing so in a listener as well causes the redundant installation.

Also did some minor clean up in GenericDialog and GenericDialogFactory to remove unused code and improve encapsulation.

Possible Drawbacks

None

Documentation Notes

N/A

Release Notes

  • Fixed a bug where MapTool would try to install resource libraries twice.

This change is Reviewable

@kwvanderlinde kwvanderlinde self-assigned this Nov 17, 2025
@github-actions github-actions bot added the bug label Nov 17, 2025
@kwvanderlinde kwvanderlinde moved this from Todo to Awaiting-Review in MapTool 1.19 Nov 17, 2025
@kwvanderlinde kwvanderlinde force-pushed the bugfix/5865-add-resource-double-install branch from 43b4c1c to 474ff21 Compare November 17, 2025 07:47
This isn't the right situation to throw an exception, since it is at least as likely to indicate a failure for previous
code to unbind the model rather than being a problem of the current caller double-binding. Throwing an exception here
has the potential to crash MT and even the OS as the exception is reported in error dialogs on repeat.

This case still indicates a logical error, though, so log it as such. But after that, just unbind the old model and
carry on.
- Make `GenericDialogFactory#delegate()` private instead of package-private.
- Do not suppress the `UnusedReturnValue` warnings in `GenericDialogFactory`, since none of these methods generate that
  warning.
- Remove unused `GenericDialog#_preferredSize` and `#getAllComponents(Container)`
- Make `GenericDialog#_resizable` private instead of `protected`.
- Use `instanceof` pattern matching in `GenericDialog` to avoid repeated casts of the content component to
  `AbeillePanel`.
- Remove commented out code in `GenericDialog`.
`GenericDialog` automatically commits the dialog since the content component is an `AbeillePanel` with a bound model.
This means we don't have to manually wire up the INSTALL button to the `#commit()` method, and in fact doing so is what
causes resource libraries to be installed doubly.

Also removes the redundant `AddResourceDialog#model` field - as an `AbeillePanel`, the `getModel()` method already
returns this same value.
@kwvanderlinde kwvanderlinde force-pushed the bugfix/5865-add-resource-double-install branch from 474ff21 to 4842e0a Compare November 17, 2025 19:30
@github-project-automation github-project-automation bot moved this from Awaiting-Review to To-Be-Merged in MapTool 1.19 Nov 18, 2025
@cwisniew cwisniew added this pull request to the merge queue Nov 18, 2025
Merged via the queue into RPTools:develop with commit 12c7005 Nov 18, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from To-Be-Merged to Merged in MapTool 1.19 Nov 18, 2025
@kwvanderlinde kwvanderlinde deleted the bugfix/5865-add-resource-double-install branch November 18, 2025 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

[Bug]: Add Resource to Library dialog double installs and errors out

2 participants