summaryrefslogtreecommitdiff
path: root/FreeFileSync/Source/lib/help_provider.h
diff options
context:
space:
mode:
Diffstat (limited to 'FreeFileSync/Source/lib/help_provider.h')
-rw-r--r--FreeFileSync/Source/lib/help_provider.h70
1 files changed, 50 insertions, 20 deletions
diff --git a/FreeFileSync/Source/lib/help_provider.h b/FreeFileSync/Source/lib/help_provider.h
index ecfa1e5e..f4c57e70 100644
--- a/FreeFileSync/Source/lib/help_provider.h
+++ b/FreeFileSync/Source/lib/help_provider.h
@@ -4,8 +4,8 @@
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
// **************************************************************************
-#ifndef HELPPROVIDER_H_INCLUDED
-#define HELPPROVIDER_H_INCLUDED
+#ifndef HELPPROVIDER_H_85930427583421563126
+#define HELPPROVIDER_H_85930427583421563126
#ifdef ZEN_WIN
#include <zen/zstring.h>
@@ -23,8 +23,7 @@ namespace zen
void displayHelpEntry(wxWindow* parent);
void displayHelpEntry(const wxString& section, wxWindow* parent);
-
-
+void uninitializeHelp(); //clean up gracefully during app shutdown: leaving this up to static destruction crashes on Win 8.1!
@@ -34,31 +33,63 @@ void displayHelpEntry(const wxString& section, wxWindow* parent);
//######################## implementation ########################
namespace impl
{
-//finish wxWidgets' job
+//finish wxWidgets' job:
#ifdef ZEN_WIN
class FfsHelpController
{
public:
- FfsHelpController()
+ static FfsHelpController& getInstance()
{
- chmHlp.Initialize(utfCvrtTo<wxString>(zen::getResourceDir()) + L"FreeFileSync.chm");
+ static FfsHelpController inst; //external linkage, despite inline definition!
+ return inst;
}
void openSection(const wxString& section, wxWindow* parent)
{
+ init();
if (section.empty())
- chmHlp.DisplayContents();
+ chmHlp->DisplayContents();
else
- chmHlp.DisplaySection(replaceCpy(section, L'/', utfCvrtTo<wxString>(FILE_NAME_SEPARATOR)));
+ chmHlp->DisplaySection(replaceCpy(section, L'/', utfCvrtTo<wxString>(FILE_NAME_SEPARATOR)));
+ }
+
+ void uninitialize()
+ {
+ if (chmHlp)
+ {
+ chmHlp->Quit(); //don't let help windows open while app is shut down! => crash on Win 8.1!
+ chmHlp.reset();
+ }
}
+
private:
- wxCHMHelpController chmHlp;
+ FfsHelpController() {}
+ ~FfsHelpController() { assert(!chmHlp); }
+
+ void init() //don't put in constructor: not needed if only uninitialize() is ever called!
+ {
+ if (!chmHlp)
+ {
+ chmHlp = make_unique<wxCHMHelpController>();
+ chmHlp->Initialize(utfCvrtTo<wxString>(zen::getResourceDir()) + L"FreeFileSync.chm");
+ }
+ }
+
+ std::unique_ptr<wxCHMHelpController> chmHlp;
};
#elif defined ZEN_LINUX || defined ZEN_MAC
class FfsHelpController
{
public:
+ static FfsHelpController& getInstance()
+ {
+ static FfsHelpController inst;
+ return inst;
+ }
+
+ void uninitialize() {}
+
void openSection(const wxString& section, wxWindow* parent)
{
wxHtmlModalHelp dlg(parent, utfCvrtTo<wxString>(zen::getResourceDir()) + L"Help/FreeFileSync.hhp", section,
@@ -70,29 +101,28 @@ public:
}
};
#endif
+}
inline
-FfsHelpController& getHelpCtrl()
+void displayHelpEntry(const wxString& section, wxWindow* parent)
{
- static FfsHelpController ctrl; //external linkage, despite inline definition!
- return ctrl;
-}
+ impl::FfsHelpController::getInstance().openSection(section, parent);
}
inline
-void displayHelpEntry(const wxString& section, wxWindow* parent)
+void displayHelpEntry(wxWindow* parent)
{
- impl::getHelpCtrl().openSection(section, parent);
+ impl::FfsHelpController::getInstance().openSection(wxString(), parent);
}
-
inline
-void displayHelpEntry(wxWindow* parent)
+void uninitializeHelp()
{
- impl::getHelpCtrl().openSection(wxString(), parent);
+ impl::FfsHelpController::getInstance().uninitialize();
+
}
}
-#endif //HELPPROVIDER_H_INCLUDED
+#endif //HELPPROVIDER_H_85930427583421563126
bgstack15