Skip to content

(really) fix map saving and renaming (save as)

username-removed-195241 requested to merge illwieckz/netradiant:fixsaving into master

@Mirio reported more issue about map saving (#105 (closed)), even after !53 (merged). This is an earlier fix I wrote for #105 (closed), but I thought !53 (merged) was enough, which wasn't. This fix revert some Neumond's code, the map observer part, since we can't apply the same task to different events, an observer is useless.

I was not able to reproduce Mirio's issue, but doing more testing I discovered refreshing was not enough on map opening or map newing for non-PK3 VFS like the DPK one, so this fix is far better.

  • [dpkdir] revert *MapFileObservers() addition, fix #105 (closed)

Neumond probably thoughts it would be cool to make a file observer that reloads the VFS each time the map change, was a nice idea. Badly, it makes the VFS reloading itself before saving a map, losing the current work done.

Would be easier to not rely on that observer mechanism and just make an explicit call to reload VFS when needed instead, so we revert this part.

This VFS reload mechanism will be reintroduced in next commit.

This commit fixes #105 (closed) even if DPK VFS is not yet fully restored.

Note: this observer mechanism was also made available to plugins, so it's not available to plugins anymore (it was not used, and it's a bad idea, see the next commit).

  • [dpkdir] restart VFS only for Map_Free() and Map_LoadFile(), refresh others

Since there is no map file observer anymore for that stuff, we Restart or Refresh it explicitely when needed.

  • Opening map or New map needs Restarting VFS.
  • Saving map or Renaming map (Save as) needs Refreshing VFS.

The Refresh also triggers the Texture browser.

A previous fix for #105 (closed) was done Refreshing VFS instead of Restarting it but it was not perfect, for example map opening behavior is better with VFS restart, and map saving needs to refresh the VFS and the texture browser but not restart (that was the earlier fault). So, it's clearly not a good idea to trigger either Refresh or Restart on any map event since the behavior differs according to the event.

If one day one plugin wants to act on VFS on map event, it must refresh or restart VFS according to what the plugin does. It does not make sense to trigger the same task for different events.

Merge request reports