Clean up private fonts on library shut down under MSW

Ensure we don't keep the values in the global gs_privateFontFileNames
variable if the library is shutdown and reinitialized later, this would
be unexpected.
This commit is contained in:
Vadim Zeitlin
2017-11-07 18:05:07 +01:00
parent 149807db26
commit 28864d3ef6

View File

@@ -30,6 +30,7 @@
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/log.h"
#include "wx/module.h"
#include "wx/msw/private.h"
#endif // WX_PRECOMP
@@ -1103,6 +1104,22 @@ extern const wxArrayString& wxGetPrivateFontFileNames()
return gs_privateFontFileNames;
}
// We need to use a module to clean up the list of private fonts when the
// library is shut down.
class wxPrivateFontsListModule : public wxModule
{
public:
wxPrivateFontsListModule() { }
bool OnInit() wxOVERRIDE { return true; }
void OnExit() wxOVERRIDE { gs_privateFontFileNames.clear(); }
private:
wxDECLARE_DYNAMIC_CLASS(wxPrivateFontsListModule);
};
wxIMPLEMENT_DYNAMIC_CLASS(wxPrivateFontsListModule, wxModule);
bool wxFontBase::AddPrivateFont(const wxString& filename)
{
if ( !wxFileName::FileExists(filename) )