From d7a80cf5cd3cd199ad7b3c08293676a393207f41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 26 Mar 2007 21:07:36 +0000 Subject: [PATCH] use wxString for wxXmlResource::Set/GetDomain(), it's simpler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45081 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/xrc/xmlres.h | 19 ++++++++++--------- src/xrc/xmlres.cpp | 18 ++++-------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/include/wx/xrc/xmlres.h b/include/wx/xrc/xmlres.h index 4af3d25824..e8d1424bd0 100644 --- a/include/wx/xrc/xmlres.h +++ b/include/wx/xrc/xmlres.h @@ -113,7 +113,7 @@ public: // don't check the modification time of the XRC files and // reload them if they have changed on disk wxXmlResource(int flags = wxXRC_USE_LOCALE, - const wxString& domain=wxEmptyString); + const wxString& domain = wxEmptyString); // Constructor. // Flags: wxXRC_USE_LOCALE @@ -123,13 +123,13 @@ public: // subclass property of object nodes will be ignored // (useful for previews in XRC editors) wxXmlResource(const wxString& filemask, int flags = wxXRC_USE_LOCALE, - const wxString& domain=wxEmptyString); + const wxString& domain = wxEmptyString); // Destructor. virtual ~wxXmlResource(); wxXmlNode *GetFirstRoot(); - + // Loads resources from XML files that match given filemask. // This method understands VFS (see filesys.h). bool Load(const wxString& filemask); @@ -249,10 +249,11 @@ public: // Set flags after construction. void SetFlags(int flags) { m_flags = flags; } - // Get/Set the domain to be passed to the translation functions, defaults to NULL. - wxChar* GetDomain() const { return m_domain; } - void SetDomain(const wxChar* domain); - + // Get/Set the domain to be passed to the translation functions, defaults + // to empty string (no domain). + const wxString& GetDomain() const { return m_domain; } + void SetDomain(const wxString& domain); + protected: // Scans the resources list for unloaded files and loads them. Also reloads // files that have been modified since last loading. @@ -293,8 +294,8 @@ private: #endif // domain to pass to translation functions, if any. - wxChar* m_domain; - + wxString m_domain; + friend class wxXmlResourceHandler; friend class wxXmlResourceModule; diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 479dbbd138..b10e7dfcb8 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -69,35 +69,25 @@ wxXmlResource::wxXmlResource(int flags, const wxString& domain) { m_flags = flags; m_version = -1; - m_domain = NULL; - if (! domain.empty() ) - SetDomain(domain); + SetDomain(domain); } wxXmlResource::wxXmlResource(const wxString& filemask, int flags, const wxString& domain) { m_flags = flags; m_version = -1; - m_domain = NULL; - if (! domain.empty() ) - SetDomain(domain); + SetDomain(domain); Load(filemask); } wxXmlResource::~wxXmlResource() { - if (m_domain) - free(m_domain); ClearHandlers(); } -void wxXmlResource::SetDomain(const wxChar* domain) +void wxXmlResource::SetDomain(const wxString& domain) { - if (m_domain) - free(m_domain); - m_domain = NULL; - if (domain && wxStrlen(domain)) - m_domain = wxStrdup(domain); + m_domain = domain; } -- 2.50.0