From 5fe8354960174a56ee21c456ac3ba521a7b9bae5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 6 Jul 2001 16:23:37 +0000 Subject: [PATCH] fixed a design flaw in wxFontMapper that prevented automatic creation of wxConfig instance git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/fontmap.h | 1 + src/common/fontmap.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/wx/fontmap.h b/include/wx/fontmap.h index 9331241a2a..70691e8afb 100644 --- a/include/wx/fontmap.h +++ b/include/wx/fontmap.h @@ -166,6 +166,7 @@ protected: #if wxUSE_CONFIG // config object and path (in it) to use wxConfigBase *m_config; + bool m_configIsDummy; #endif wxString m_configRootPath; diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 977f7b2c44..8b159319d4 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -215,6 +215,7 @@ wxFontMapper::wxFontMapper() { #if wxUSE_CONFIG m_config = NULL; + m_configIsDummy = FALSE; #endif // wxUSE_CONFIG #if wxUSE_GUI @@ -264,10 +265,27 @@ wxConfigBase *wxFontMapper::GetConfig() // but will allow us to remember the results of the questions at // least during this run m_config = new wxMemoryConfig; - wxConfig::Set(m_config); + m_configIsDummy = TRUE; + // VS: we can't call wxConfig::Set(m_config) here because that would + // disable automatic wxConfig instance creation if this code was + // called before wxApp::OnInit (this happens in wxGTK -- it sets + // default wxFont encoding in wxApp::Initialize()) } } + if ( m_configIsDummy && wxConfig::Get(FALSE) != NULL ) + { + // VS: in case we created dummy m_config (see above), we want to switch back + // to the real one as soon as one becomes available. + m_config = wxConfig::Get(FALSE); + m_configIsDummy = FALSE; + // FIXME: ideally, we should add keys from dummy config to the real one now, + // but it is a low-priority task because typical wxWin application + // either doesn't use wxConfig at all or creates wxConfig object in + // wxApp::OnInit(), before any real interaction with the user takes + // place... + } + return m_config; } -- 2.45.2