widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04354
[Merge] lp:~meitis/widelands/bug1493972 into lp:widelands
meitis has proposed merging lp:~meitis/widelands/bug1493972 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1493972 in widelands: "editor load / save menu has issues with nested directories of the same name"
https://bugs.launchpad.net/widelands/+bug/1493972
For more details, see:
https://code.launchpad.net/~meitis/widelands/bug1493972/+merge/270897
--
Your team Widelands Developers is requested to review the proposed merge of lp:~meitis/widelands/bug1493972 into lp:widelands.
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc 2015-08-06 17:14:34 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2015-09-13 14:15:58 +0000
@@ -161,16 +161,21 @@
void MainMenuSaveMap::clicked_ok() {
assert(m_ok_btn->enabled());
std::string filename = m_editbox->text();
+ std::string complete_filename;
if (filename == "") // Maybe a directory is selected.
- filename = m_ls->get_selected();
+ {
+ complete_filename = filename = m_ls->get_selected();
+ } else {
+ complete_filename = m_curdir + "/" + filename;
+ }
if
- (g_fs->is_directory(filename.c_str())
+ (g_fs->is_directory(complete_filename.c_str())
&&
- !Widelands::WidelandsMapLoader::is_widelands_map(filename))
+ !Widelands::WidelandsMapLoader::is_widelands_map(complete_filename))
{
- m_curdir = g_fs->canonicalize_name(filename);
+ m_curdir = complete_filename;
m_ls->clear();
m_mapfiles.clear();
fill_list();
@@ -209,7 +214,7 @@
void MainMenuSaveMap::clicked_make_directory() {
MainMenuSaveMapMakeDirectory md(this, _("unnamed"));
if (md.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kOk) {
- g_fs->ensure_directory_exists(m_basedir);
+ g_fs->ensure_directory_exists(m_curdir);
// create directory
std::string fullname = m_curdir;
fullname += "/";
@@ -362,8 +367,8 @@
* should stay open
*/
bool MainMenuSaveMap::save_map(std::string filename, bool binary) {
- // Make sure that the base directory exists.
- g_fs->ensure_directory_exists(m_basedir);
+ // Make sure that the current directory exists and is writeable.
+ g_fs->ensure_directory_exists(m_curdir);
// OK, first check if the extension matches (ignoring case).
if (!boost::iends_with(filename, WLMF_SUFFIX))