]> git.saurik.com Git - wxWidgets.git/commitdiff
assert in AddCatalog() if Init() hadn't been called and also check that we have a...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 14 Nov 2008 19:06:59 +0000 (19:06 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 14 Nov 2008 19:06:59 +0000 (19:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/internat/internat.cpp
src/common/intl.cpp

index 96f289c2c6f421ae2d36a1e608495e282f6c3438..77d62a296d7adb9b785abf04971c49ac46d23bb7 100644 (file)
@@ -218,16 +218,13 @@ bool MyApp::OnInit()
         m_lang = lng == -1 ? wxLANGUAGE_DEFAULT : langIds[lng];
     }
 
-    if ( m_lang != wxLANGUAGE_DEFAULT )
+    // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
+    // false just because it failed to load wxstd catalog
+    if ( !m_locale.Init(m_lang, wxLOCALE_CONV_ENCODING) )
     {
-        // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
-        // false just because it failed to load wxstd catalog
-        if ( !m_locale.Init(m_lang, wxLOCALE_CONV_ENCODING) )
-        {
-            wxLogWarning(_("This language is not supported by the system."));
+        wxLogWarning(_("This language is not supported by the system."));
 
-            // continue nevertheless
-        }
+        // continue nevertheless
     }
 
     // normally this wouldn't be necessary as the catalog files would be found
index a1f81ebec7464d3fd16d0dbf167aaff2f91eaf16..39cd1a0c3f05146470d2eacbe114852bf310bb41 100644 (file)
@@ -1177,6 +1177,9 @@ static wxString GetFullSearchPath(const wxString& lang)
 bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
                             wxPluralFormsCalculatorPtr& rPluralFormsCalculator)
 {
+    wxCHECK_MSG( szDirPrefix.length() >= LEN_LANG, false,
+                    "invalid language specification" );
+
   wxString searchPath;
 
 #if wxUSE_FONTMAP
@@ -2570,6 +2573,8 @@ bool wxLocale::AddCatalog(const wxString& szDomain,
                           const wxString& msgIdCharset)
 
 {
+    wxCHECK_MSG( IsOk(), false, "must initialize catalog first" );
+
     wxMsgCatalog *pMsgCat = new wxMsgCatalog;
 
     if ( pMsgCat->Load(m_strShort, szDomain, msgIdCharset, m_bConvertEncoding) )