diff options
Diffstat (limited to 'RealtimeSync')
-rw-r--r-- | RealtimeSync/RealtimeSync.vcxproj | 8 | ||||
-rw-r--r-- | RealtimeSync/application.cpp | 11 | ||||
-rw-r--r-- | RealtimeSync/application.h | 1 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.cpp | 30 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.h | 14 | ||||
-rw-r--r-- | RealtimeSync/makefile | 6 | ||||
-rw-r--r-- | RealtimeSync/resources.cpp | 6 | ||||
-rw-r--r-- | RealtimeSync/resources.h | 2 |
8 files changed, 55 insertions, 23 deletions
diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj index 73674abc..097f9965 100644 --- a/RealtimeSync/RealtimeSync.vcxproj +++ b/RealtimeSync/RealtimeSync.vcxproj @@ -70,28 +70,28 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <LinkIncremental>true</LinkIncremental> <OutDir>..\BUILD\Bin\</OutDir> - <IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir> + <IntDir>..\OBJ\$(ProjectName)_VCPP_$(PlatformName)_$(Configuration)\</IntDir> <GenerateManifest>false</GenerateManifest> <TargetName>$(ProjectName)_$(PlatformName)</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <LinkIncremental>true</LinkIncremental> <OutDir>..\BUILD\Bin\</OutDir> - <IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir> + <IntDir>..\OBJ\$(ProjectName)_VCPP_$(PlatformName)_$(Configuration)\</IntDir> <GenerateManifest>false</GenerateManifest> <TargetName>$(ProjectName)_$(PlatformName)</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <LinkIncremental>false</LinkIncremental> <OutDir>..\BUILD\Bin\</OutDir> - <IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir> + <IntDir>..\OBJ\$(ProjectName)_VCPP_$(PlatformName)_$(Configuration)\</IntDir> <GenerateManifest>false</GenerateManifest> <TargetName>$(ProjectName)_$(PlatformName)</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <LinkIncremental>false</LinkIncremental> <OutDir>..\BUILD\Bin\</OutDir> - <IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir> + <IntDir>..\OBJ\$(ProjectName)_VCPP_$(PlatformName)_$(Configuration)\</IntDir> <GenerateManifest>false</GenerateManifest> <TargetName>$(ProjectName)_$(PlatformName)</TargetName> </PropertyGroup> diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp index 1efed1a1..61c9ca96 100644 --- a/RealtimeSync/application.cpp +++ b/RealtimeSync/application.cpp @@ -77,8 +77,7 @@ bool Application::OnInit() ::TransformProcessType(&psn, kProcessTransformToForegroundApplication); //behave like an application bundle, even when the app is not packaged (yet) #endif - warn_static("fix") - SetAppName(L"FreeFileSync"); //abuse FFS's name, to have "GetUserDataDir()" return the same directory + SetAppName(L"FreeFileSync"); //reuse FFS's name, to have "GetUserDataDir()/GetResourcesDir()" return the same directory in ffs_paths.cpp //do not call wxApp::OnInit() to avoid using default commandline parser @@ -91,6 +90,13 @@ bool Application::OnInit() } +int Application::OnExit() +{ + releaseWxLocale(); + return wxApp::OnExit(); +} + + void Application::onEnterEventLoop(wxEvent& event) { Disconnect(EVENT_ENTER_EVENT_LOOP, wxEventHandler(Application::onEnterEventLoop), nullptr, this); @@ -162,4 +168,3 @@ int Application::OnRun() return FFS_RC_SUCCESS; //program's return code } - diff --git a/RealtimeSync/application.h b/RealtimeSync/application.h index b3c302d7..2edef90c 100644 --- a/RealtimeSync/application.h +++ b/RealtimeSync/application.h @@ -13,6 +13,7 @@ class Application : public wxApp { public: virtual bool OnInit(); + virtual int OnExit(); virtual int OnRun(); virtual bool OnExceptionInMainLoop() { throw; } //just re-throw and avoid display of additional messagebox: it will be caught in OnRun() diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp index 55d33fa1..f0d4d4f7 100644 --- a/RealtimeSync/main_dlg.cpp +++ b/RealtimeSync/main_dlg.cpp @@ -52,7 +52,7 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) #endif wxWindowUpdateLocker dummy(this); //avoid display distortion - SetIcon(GlobalResources::instance().programIcon); //set application icon + SetIcon(GlobalResources::instance().programIconRTS); //set application icon setRelativeFontSize(*m_buttonStart, 1.5); m_buttonStart->setInnerBorderSize(8); @@ -115,6 +115,8 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) //drag and drop .ffs_real and .ffs_batch on main dialog setupFileDrop(*m_panelMain); m_panelMain->Connect(EVENT_DROP_FILE, FileDropEventHandler(MainDialog::onFilesDropped), nullptr, this); + + timerForAsyncTasks.Connect(wxEVT_TIMER, wxEventHandler(MainDialog::onProcessAsyncTasks), nullptr, this); } @@ -134,6 +136,15 @@ MainDialog::~MainDialog() } +void MainDialog::onProcessAsyncTasks(wxEvent& event) +{ + //schedule and run long-running tasks asynchronously + asyncTasks.evalResults(); //process results on GUI queue + if (asyncTasks.empty()) + timerForAsyncTasks.Stop(); +} + + const wxString& MainDialog::lastConfigFileName() { static wxString instance = toWx(zen::getConfigDir()) + L"LastRun.ffs_real"; @@ -423,20 +434,23 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron } -void MainDialog::removeAddFolder(int pos) +void MainDialog::removeAddFolder(size_t pos) { wxWindowUpdateLocker dummy(this); //avoid display distortion - if (0 <= pos && pos < static_cast<int>(dirNamesExtra.size())) + if (pos < dirNamesExtra.size()) { //remove folder pairs from window - DirectoryPanel* dirToDelete = dirNamesExtra[pos]; - const int folderHeight = dirToDelete->GetSize().GetHeight(); + DirectoryPanel* pairToDelete = dirNamesExtra[pos]; + const int folderHeight = pairToDelete->GetSize().GetHeight(); - bSizerFolders->Detach(dirToDelete); //Remove() does not work on Window*, so do it manually - dirToDelete->Destroy(); // + bSizerFolders->Detach(pairToDelete); //Remove() does not work on Window*, so do it manually dirNamesExtra.erase(dirNamesExtra.begin() + pos); //remove last element in vector - + //more (non-portable) wxWidgets bullshit: on OS X wxWindow::Destroy() screws up and calls "operator delete" directly rather than + //the deferred deletion it is expected to do (and which is implemented correctly on Windows and Linux) + //http://bb10.com/python-wxpython-devel/2012-09/msg00004.html + //=> since we're in a mouse button callback of a sub-component of "pairToDelete" we need to delay deletion ourselves: + processAsync2([] {}, [pairToDelete] { pairToDelete->Destroy(); }); //set size of scrolled window const size_t additionalRows = std::min(dirNamesExtra.size(), MAX_ADD_FOLDERS); //up to MAX_ADD_FOLDERS additional folders shall be shown diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h index f5fed970..5a028f3a 100644 --- a/RealtimeSync/main_dlg.h +++ b/RealtimeSync/main_dlg.h @@ -12,6 +12,7 @@ #include <memory> #include <wx+/file_drop.h> #include "../ui/dir_name.h" +#include <zen/async_task.h> namespace xmlAccess { @@ -50,7 +51,7 @@ private: void addFolder(const wxString& dirname, bool addFront = false); void addFolder(const std::vector<wxString>& newFolders, bool addFront = false); - void removeAddFolder(int pos); //keep it an int, allow negative values! + void removeAddFolder(size_t pos); void clearAddFolders(); static const wxString& lastConfigFileName(); @@ -59,6 +60,17 @@ private: std::vector<DirectoryPanel*> dirNamesExtra; //additional pairs to the standard pair wxString currentConfigFileName; + + void onProcessAsyncTasks(wxEvent& event); + + template <class Fun, class Fun2> + void processAsync(Fun doAsync, Fun2 evalOnGui) { asyncTasks.add(doAsync, evalOnGui); timerForAsyncTasks.Start(50); /*timer interval in [ms] */ } + template <class Fun, class Fun2> + void processAsync2(Fun doAsync, Fun2 evalOnGui) { asyncTasks.add2(doAsync, evalOnGui); timerForAsyncTasks.Start(50); /*timer interval in [ms] */ } + + //schedule and run long-running tasks asynchronously, but process results on GUI queue + zen::AsyncTasks asyncTasks; + wxTimer timerForAsyncTasks; //don't use wxWidgets idle handling => repeated idle requests/consumption hogs 100% cpu! }; #endif // REALTIMESYNCMAIN_H diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile index 82909526..325578a1 100644 --- a/RealtimeSync/makefile +++ b/RealtimeSync/makefile @@ -77,11 +77,11 @@ CPP_LIST+=../zen/zstring.cpp CPP_LIST+=../wx+/button.cpp #list of all *.o files (we need the "RTS" subdirectory to handle "../*.cpp" files -OBJECT_LIST=$(CPP_LIST:%.cpp=../OBJ/RTS_Release_GCC_Make/RTS/%.o) +OBJECT_LIST=$(CPP_LIST:%.cpp=../OBJ/RTS_GCC_Make_Release/RTS/%.o) all: RealtimeSync -../OBJ/RTS_Release_GCC_Make/RTS/%.o : %.cpp +../OBJ/RTS_GCC_Make_Release/RTS/%.o : %.cpp mkdir -p $(dir $@) $(COMPILER_BIN) $(CXXFLAGS) -c $< -o $@ @@ -89,7 +89,7 @@ RealtimeSync: $(OBJECT_LIST) $(COMPILER_BIN) -o ../BUILD/$(APPNAME) $(OBJECT_LIST) $(LINKFLAGS) clean: - rm -rf ../OBJ/RTS_Release_GCC_Make + rm -rf ../OBJ/RTS_GCC_Make_Release rm -f ../BUILD/$(APPNAME) rm -f ../wx+/pch.h.gch diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp index 2b31ad12..f55887ee 100644 --- a/RealtimeSync/resources.cpp +++ b/RealtimeSync/resources.cpp @@ -49,16 +49,16 @@ GlobalResources::GlobalResources() #ifdef FFS_WIN //for compatibility it seems we need to stick with a "real" icon - programIcon = wxIcon(L"A_PROGRAM_ICON"); + programIconRTS = wxIcon(L"A_RTS_ICON"); #elif defined FFS_LINUX - programIcon.CopyFromBitmap(getImage(L"RealtimeSync")); + programIconRTS.CopyFromBitmap(getImage(L"RealtimeSync")); #elif defined FFS_MAC assert(getImage(L"RealtimeSync").GetWidth () == getImage(L"RealtimeSync").GetHeight() && getImage(L"RealtimeSync").GetWidth() % 128 == 0); //wxWidgets' bitmap to icon conversion on OS X can only deal with very specific sizes - programIcon.CopyFromBitmap(getImage(L"RealtimeSync").ConvertToImage().Scale(128, 128, wxIMAGE_QUALITY_HIGH)); + programIconRTS.CopyFromBitmap(getImage(L"RealtimeSync").ConvertToImage().Scale(128, 128, wxIMAGE_QUALITY_HIGH)); #endif } diff --git a/RealtimeSync/resources.h b/RealtimeSync/resources.h index 623265f3..7cec3a73 100644 --- a/RealtimeSync/resources.h +++ b/RealtimeSync/resources.h @@ -20,7 +20,7 @@ public: const wxBitmap& getImage(const wxString& name) const; //image resource objects - wxIcon programIcon; + wxIcon programIconRTS; private: GlobalResources(); |