Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed map reload in case map is open as part of a world #3939

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

bjorn
Copy link
Member

@bjorn bjorn commented May 1, 2024

This is a re-implementation of the way maps are reloaded, to make sure the reload affects all instances and not just the opened editor tab. Previously, the reload was implemented by closing and reopening that tab, which was only a viable method before the implementation of worlds.

This is a rather risky change since the code was never prepared for the map and its internal structures to be replaced entirely without any specific change events. There's a high probability of leaving a roaming pointer somewhere.

Marked as draft because there are a few open tasks:

  • Needs much more testing.
  • Would be nice to restore object and layer selection after the reload when possible.

Fixes part of issue #3927 (though not entirely, since that would require watching map files for changes also when they aren't open in their own tab).

bjorn added 2 commits May 2, 2024 20:32
This is a re-implementation of the way maps are reloaded, to make sure
the reload affects all instances and not just the opened editor tab.
Previously, the reload was implemented by closing and reopening that
tab, which was only a viable method before the implementation of worlds.

This is a rather risky change since the code was never prepared for the
map and its internal structures to be replaced entirely without any
specific change events. There's a high probability of leaving a roaming
pointer somewhere.
src/tiled/mapitem.cpp Outdated Show resolved Hide resolved
bjorn added 2 commits May 16, 2024 17:46
* Unset mWangSet pointers on WangSet destruction. I'd really like to
  stop using shared pointers instead, since the WangSet should really own
  its WangColors, but that'll be a bigger change.

* WangDock resets its current WangSet before reload and re-initializes it
  afterwards.

* WangSetModel resets on reload and WangDock was adjusted to make sure
  all rows are expanded after a model reset.

* When a Document is about to be reloaded, make sure any current object
  referenced from another Document is reset.

* TilesetView refreshes the column count after tileset reload, which
  might have changed when dynamic wrapping is enabled and the tile size
  changed.

* TilesetDocument now clears mWangColorModels upon reload.

* TileSelectionItem refreshes its geometry after map reload.

* Addressed code duplication in LayerView.

* TilesetWangSetModel refreshes as appropriate after tileset reload.
When restoring object selection after the layers, and all selected objects
are from the same layer, it would reset the layer selection to only that
layer.
@bjorn bjorn marked this pull request as ready for review May 16, 2024 15:47
bjorn added 8 commits May 17, 2024 13:34
Because some scripts will want to respond to this, especially since it
means a new editable has been created, which needs signals to be
reconnected

(it would be nice if we could reuse the existing editable, though this
is problematic since it might have created many child editables that
point directly to the previous contents)
Also avoid multiple connections to
DocumentManager::templateTilesetReplaced.
Cause in that case, the BrokenLinksModel would have connected first to
the Document::changed signal.
It shouldn't be always enabled for maps, since we can only reload maps
when they have a file name and we know the file format.

Also made some "final" tweaks.
Instead, the script wrapper now handles the AboutToReload and Reloaded
signals, in order to detach relevant script objects and to update its
object reference.
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.

None yet

1 participant