diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:17:25 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:17:25 +0200 |
commit | 94e1d2e78b6ff92d5a1c971c277cb6ac792d1c70 (patch) | |
tree | 338d2ab72f79901f5d32c96d63cec36f30bcf44e /lib | |
parent | 4.4 (diff) | |
download | FreeFileSync-94e1d2e78b6ff92d5a1c971c277cb6ac792d1c70.tar.gz FreeFileSync-94e1d2e78b6ff92d5a1c971c277cb6ac792d1c70.tar.bz2 FreeFileSync-94e1d2e78b6ff92d5a1c971c277cb6ac792d1c70.zip |
4.5
Diffstat (limited to 'lib')
-rw-r--r-- | lib/folder_history_box.cpp | 7 | ||||
-rw-r--r-- | lib/folder_history_box.h | 6 | ||||
-rw-r--r-- | lib/resolve_path.cpp | 13 |
3 files changed, 16 insertions, 10 deletions
diff --git a/lib/folder_history_box.cpp b/lib/folder_history_box.cpp index b395cbf4..c8bd042a 100644 --- a/lib/folder_history_box.cpp +++ b/lib/folder_history_box.cpp @@ -60,8 +60,8 @@ void FolderHistoryBox::OnHideDropDown(wxCommandEvent& event) } #endif - -void FolderHistoryBox::update(const wxString& dirname) +//set value and update list are technically entangled: see potential bug description below +void FolderHistoryBox::setValueAndUpdateList(const wxString& dirname) { //it may be a little lame to update the list on each mouse-button click, but it should be working and we dont't have to manipulate wxComboBox internals @@ -69,8 +69,7 @@ void FolderHistoryBox::update(const wxString& dirname) //add some aliases to allow user changing to volume name and back, if possible #ifdef FFS_WIN - const Zstring activePath = toZ(GetValue()); - std::vector<Zstring> aliases = getDirectoryAliases(activePath); + std::vector<Zstring> aliases = getDirectoryAliases(toZ(dirname)); dirList.insert(dirList.end(), aliases.begin(), aliases.end()); #endif diff --git a/lib/folder_history_box.h b/lib/folder_history_box.h index 28b85c90..859234cc 100644 --- a/lib/folder_history_box.h +++ b/lib/folder_history_box.h @@ -80,7 +80,7 @@ public: void setValue(const wxString& dirname) { - update(dirname); //required for setting value correctly + Linux to ensure the dropdown is shown as being populated + setValueAndUpdateList(dirname); //required for setting value correctly + Linux to ensure the dropdown is shown as being populated } // GetValue @@ -88,9 +88,9 @@ public: private: void OnKeyEvent(wxKeyEvent& event); void OnSelection(wxCommandEvent& event); - void OnUpdateList(wxEvent& event) { update(GetValue()); event.Skip(); } + void OnUpdateList(wxEvent& event) { setValueAndUpdateList(GetValue()); event.Skip(); } - void update(const wxString& dirname); + void setValueAndUpdateList(const wxString& dirname); #if wxCHECK_VERSION(2, 9, 1) void OnShowDropDown(wxCommandEvent& event); diff --git a/lib/resolve_path.cpp b/lib/resolve_path.cpp index feeb98e3..df65b98b 100644 --- a/lib/resolve_path.cpp +++ b/lib/resolve_path.cpp @@ -5,6 +5,7 @@ #include <map> #include <set> #include <zen/scope_guard.h> +#include <zen/thread.h> #ifdef FFS_WIN #include <zen/dll.h> @@ -354,6 +355,7 @@ Zstring volumenNameToPath(const Zstring& volumeName) //return empty string on er #ifdef FFS_WIN +//attention: this call may seriously block if network volume is not available!!! Zstring volumePathToName(const Zstring& volumePath) //return empty string on error { const DWORD bufferSize = MAX_PATH + 1; @@ -440,9 +442,14 @@ void getDirectoryAliasesRecursive(const Zstring& dirname, std::set<Zstring, Less dirname[1] == L':' && dirname[2] == L'\\') { - Zstring volname = volumePathToName(Zstring(dirname.c_str(), 3)); - if (!volname.empty()) - output.insert(L"[" + volname + L"]" + Zstring(dirname.c_str() + 2)); + //attention: "volumePathToName()" will seriously block if network volume is not available!!! + boost::unique_future<Zstring> futVolName = zen::async([=] { return volumePathToName(Zstring(dirname.c_str(), 3)); }); + if (futVolName.timed_wait(boost::posix_time::seconds(1))) + { + Zstring volname = futVolName.get(); + if (!volname.empty()) + output.insert(L"[" + volname + L"]" + Zstring(dirname.c_str() + 2)); + } } //2. replace volume name by volume path: [SYSTEM]\dirname -> c:\dirname |