diff options
Diffstat (limited to 'FreeFileSync/Source/RealTimeSync/application.cpp')
-rw-r--r-- | FreeFileSync/Source/RealTimeSync/application.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/FreeFileSync/Source/RealTimeSync/application.cpp b/FreeFileSync/Source/RealTimeSync/application.cpp index 2804838c..7e408979 100644 --- a/FreeFileSync/Source/RealTimeSync/application.cpp +++ b/FreeFileSync/Source/RealTimeSync/application.cpp @@ -33,7 +33,7 @@ IMPLEMENT_APP(Application) namespace { -const wxEventType EVENT_ENTER_EVENT_LOOP = wxNewEventType(); +wxDEFINE_EVENT(EVENT_ENTER_EVENT_LOOP, wxCommandEvent); } @@ -65,9 +65,7 @@ bool Application::OnInit() (fff::getResourceDirPf() + fileName).c_str(), //const gchar* path, &error); //GError** error if (error) - throw SysError(formatSystemError("gtk_css_provider_load_from_path", - replaceCpy(_("Error code %x"), L"%x", numberTo<std::wstring>(error->code)), - utfTo<std::wstring>(error->message))); + throw SysError(formatGlibError("gtk_css_provider_load_from_path", error)); ::gtk_style_context_add_provider_for_screen(::gdk_screen_get_default(), //GdkScreen* screen, GTK_STYLE_PROVIDER(provider), //GtkStyleProvider* provider, @@ -93,7 +91,7 @@ bool Application::OnInit() //Windows User Experience Interaction Guidelines: tool tips should have 5s timeout, info tips no timeout => compromise: wxToolTip::Enable(true); //yawn, a wxWidgets screw-up: wxToolTip::SetAutoPop is no-op if global tooltip window is not yet constructed: wxToolTip::Enable creates it - wxToolTip::SetAutoPop(10000); //https://docs.microsoft.com/en-us/windows/win32/uxguide/ctrl-tooltips-and-infotips + wxToolTip::SetAutoPop(10'000); //https://docs.microsoft.com/en-us/windows/win32/uxguide/ctrl-tooltips-and-infotips SetAppName(L"RealTimeSync"); @@ -109,11 +107,11 @@ bool Application::OnInit() } - Connect(wxEVT_QUERY_END_SESSION, wxEventHandler(Application::onQueryEndSession), nullptr, this); - Connect(wxEVT_END_SESSION, wxEventHandler(Application::onQueryEndSession), nullptr, this); + Bind(wxEVT_QUERY_END_SESSION, [this](wxCloseEvent& event) { onQueryEndSession(event); }); //can veto + Bind(wxEVT_END_SESSION, [this](wxCloseEvent& event) { onQueryEndSession(event); }); //can *not* veto //Note: app start is deferred: -> see FreeFileSync - Connect(EVENT_ENTER_EVENT_LOOP, wxEventHandler(Application::onEnterEventLoop), nullptr, this); + Bind(EVENT_ENTER_EVENT_LOOP, &Application::onEnterEventLoop, this); wxCommandEvent scrollEvent(EVENT_ENTER_EVENT_LOOP); AddPendingEvent(scrollEvent); return true; //true: continue processing; false: exit immediately. @@ -133,7 +131,8 @@ wxLayoutDirection Application::GetLayoutDirection() const { return fff::getLayou void Application::onEnterEventLoop(wxEvent& event) { - Disconnect(EVENT_ENTER_EVENT_LOOP, wxEventHandler(Application::onEnterEventLoop), nullptr, this); + [[maybe_unused]] bool ubOk = Unbind(EVENT_ENTER_EVENT_LOOP, &Application::onEnterEventLoop, this); + assert(ubOk); //try to set config/batch- filepath set by %1 parameter std::vector<Zstring> commandArgs; @@ -175,7 +174,7 @@ void Application::OnUnhandledException() //handles both wxApp::OnInit() + wxApp: { try { - throw; //just re-throw and avoid display of additional messagebox + throw; //just re-throw } catch (const std::bad_alloc& e) //the only kind of exception we don't want crash dumps for { |