← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1548932-editor-save-zip-2 into lp:widelands

 

Miroslav Remák has proposed merging lp:~widelands-dev/widelands/bug-1548932-editor-save-zip-2 into lp:widelands.

Commit message:
Fix failure to overwrite currently loaded map on Windows

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1548932-editor-save-zip-2/+merge/294067

Destroy the map file system while saving the map. This will make sure that the .wmf file is unlocked on Windows.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1548932-editor-save-zip-2 into lp:widelands.
=== modified file 'src/editor/ui_menus/main_menu_save_map.cc'
--- src/editor/ui_menus/main_menu_save_map.cc	2016-05-06 08:27:24 +0000
+++ src/editor/ui_menus/main_menu_save_map.cc	2016-05-07 19:19:47 +0000
@@ -283,6 +283,7 @@
 			delete wms;
 			// Reset filesystem to avoid file locks on saves
 			fs.reset();
+			map.reset_filesystem();
 			eia().set_need_save(false);
 			g_fs->fs_unlink(complete_filename);
 			g_fs->fs_rename(tmp_name, complete_filename);

=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc	2016-03-08 15:21:41 +0000
+++ src/io/filesystem/disk_filesystem.cc	2016-05-07 19:19:47 +0000
@@ -450,7 +450,7 @@
 	if (rename(fullname1.c_str(), fullname2.c_str()) != 0)
 		throw wexception("DiskFileSystem: unable to rename %s to %s: %s",
 							fullname1.c_str(),
-							fullname1.c_str(),
+							fullname2.c_str(),
 							strerror(errno));
 }
 

=== modified file 'src/logic/map.cc'
--- src/logic/map.cc	2016-04-24 08:19:14 +0000
+++ src/logic/map.cc	2016-05-07 19:19:47 +0000
@@ -460,6 +460,11 @@
 	filesystem_.swap(fs);
 }
 
+void Map::reset_filesystem()
+{
+	filesystem_.reset();
+}
+
 FileSystem* Map::filesystem() const {
 	return filesystem_.get();
 }

=== modified file 'src/logic/map.h'
--- src/logic/map.h	2016-04-11 06:45:29 +0000
+++ src/logic/map.h	2016-05-07 19:19:47 +0000
@@ -221,6 +221,7 @@
 	FileSystem* filesystem() const;
 	// swap the filesystem after load / save
 	void swap_filesystem(std::unique_ptr<FileSystem>& fs);
+	void reset_filesystem();
 
 	// informational functions
 	const std::string& get_filename()    const {return filename_;}


Follow ups