From 9c1d2aa29cdfa5da6a04186d7fb2949fa6ef3861 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 13 May 2009 21:54:30 +0000 Subject: [PATCH] fix handling of wxBitmap nodes broken by previous changes; remove the special case of passing empty attribute name to GetBitmap/Icon(wxString) and use the overload taking wxXmlNode directly instead git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60624 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/xrc/xh_bmp.cpp | 4 +--- src/xrc/xmlres.cpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/xrc/xh_bmp.cpp b/src/xrc/xh_bmp.cpp index a91318801b..8ac3a6982d 100644 --- a/src/xrc/xh_bmp.cpp +++ b/src/xrc/xh_bmp.cpp @@ -32,9 +32,7 @@ wxBitmapXmlHandler::wxBitmapXmlHandler() wxObject *wxBitmapXmlHandler::DoCreateResource() { - // NB: empty parameter name means "take directly from this node's next - // instead of from subnode with given name" - return new wxBitmap(GetBitmap(wxEmptyString)); + return new wxBitmap(GetBitmap(m_node)); } bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node) diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 988d73027a..d19bdec665 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1334,13 +1334,29 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, const wxArtClient& defaultArtClient, wxSize size) { - return GetBitmap(GetParamNode(param), defaultArtClient, size); + // it used to be possible to pass an empty string here to indicate that the + // bitmap name should be read from this node itself but this is not + // supported any more because GetBitmap(m_node) can be used directly + // instead + wxASSERT_MSG( !param.empty(), "bitmap parameter name can't be empty" ); + + const wxXmlNode* const node = GetParamNode(param); + + if ( !node ) + { + // this is not an error as bitmap parameter could be optional + return wxNullBitmap; + } + + return GetBitmap(node, defaultArtClient, size); } wxBitmap wxXmlResourceHandler::GetBitmap(const wxXmlNode* node, const wxArtClient& defaultArtClient, wxSize size) { + wxCHECK_MSG( node, wxNullBitmap, "bitmap node can't be NULL" ); + /* If the bitmap is specified as stock item, query wxArtProvider for it: */ wxString art_id, art_client; if ( GetStockArtAttrs(node, defaultArtClient, @@ -1389,7 +1405,18 @@ wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, const wxArtClient& defaultArtClient, wxSize size) { - return GetIcon(GetParamNode(param), defaultArtClient, size); + // see comment in GetBitmap(wxString) overload + wxASSERT_MSG( !param.empty(), "icon parameter name can't be empty" ); + + const wxXmlNode* const node = GetParamNode(param); + + if ( !node ) + { + // this is not an error as icon parameter could be optional + return wxIcon(); + } + + return GetIcon(node, defaultArtClient, size); } wxIcon wxXmlResourceHandler::GetIcon(const wxXmlNode* node, -- 2.47.2