X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f396e5a7ca14cd432fd7a7a60624bd9fe0ed7a83..fce611e426eb2befea2e6a6dba765f7a817b69bd:/src/xrc/xmlres.cpp diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 00af7a26f9..c69e3bb24b 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -235,6 +235,7 @@ bool wxXmlResource::Unload(const wxString& filename) { if ( (*i)->File == fnd ) { + delete *i; Data().erase(i); unloaded = true; @@ -966,7 +967,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param, bool translate) #else // The string is internally stored as UTF-8, we have to convert // it into system's default encoding so that it can be displayed: - return wxString(str2.mb_str(wxConvUTF8), wxConvLocal); + return wxString(str2.wc_str(wxConvUTF8), wxConvLocal); #endif } } @@ -994,6 +995,7 @@ float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv) { wxString str = GetParamValue(param); +#if wxUSE_LOCALE // strings in XRC always use C locale but wxString::ToDouble() uses the // current one, so transform the string to it supposing that the only // difference between them is the decimal separator @@ -1001,6 +1003,7 @@ float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv) // TODO: use wxString::ToCDouble() when we have it str.Replace(wxT("."), wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER)); +#endif // wxUSE_LOCALE double value; if (!str.ToDouble(&value)) @@ -1575,7 +1578,10 @@ void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode * struct XRCID_record { - int id; + /* Hold the id so that once an id is allocated for a name, it + does not get created again by NewControlId at least + until we are done with it */ + wxWindowIDRef id; char *key; XRCID_record *next; }; @@ -1648,11 +1654,6 @@ static void CleanXRCID_Record(XRCID_record *rec) { CleanXRCID_Record(rec->next); - // if we had generated the value of this id automatically, release it - // now that we don't need it any longer - if ( wxWindow::IsAutoGeneratedId(rec->id) ) - wxWindow::ReleaseControlId(rec->id); - free(rec->key); delete rec; } @@ -1783,6 +1784,17 @@ static void AddStdXRCID_Records() // --------------- module and globals ----------------------------- +// normally we would do the cleanup from wxXmlResourceModule::OnExit() but it +// can happen that some XRC records have been created because of the use of +// XRCID() in event tables, which happens during static objects initialization, +// but then the application initialization failed and so the wx modules were +// neither initialized nor cleaned up -- this static object does the cleanup in +// this case +static struct wxXRCStaticCleanup +{ + ~wxXRCStaticCleanup() { CleanXRCID_Records(); } +} s_staticCleanup; + class wxXmlResourceModule: public wxModule { DECLARE_DYNAMIC_CLASS(wxXmlResourceModule)