]> git.saurik.com Git - wxWidgets.git/commitdiff
optimized <object_ref> handling for the common case of simple reference with no overw...
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 3 May 2009 07:10:23 +0000 (07:10 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 3 May 2009 07:10:23 +0000 (07:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/xrc/xmlres.cpp

index 090d7da5f2c8cbbf54b7af9f3a2e839cd68e3c2f..e9942ba2850af3b982190bd6f9ca3ab1f02074ba 100644 (file)
@@ -844,14 +844,31 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent,
             return NULL;
         }
 
-        wxXmlNode copy(*refNode);
-        MergeNodesOver(copy, *node, GetFileNameFromNode(node, Data()));
+        if ( !node->GetChildren() )
+        {
+            // In the typical, simple case, <object_ref> is used to link
+            // to another node and doesn't have any content of its own that
+            // would overwrite linked object's properties. In this case,
+            // we can simply create the resource from linked node.
+
+            return CreateResFromNode(refNode, parent, instance);
+        }
+        else
+        {
+            // In the more complicated (but rare) case, <object_ref> has
+            // subnodes that partially overwrite content of the referenced
+            // object. In this case, we need to merge both XML trees and
+            // load the resource from result of the merge.
+
+            wxXmlNode copy(*refNode);
+            MergeNodesOver(copy, *node, GetFileNameFromNode(node, Data()));
 
-        // remember referenced object's file, see GetFileNameFromNode()
-        copy.AddAttribute(ATTR_INPUT_FILENAME,
-                          GetFileNameFromNode(refNode, Data()));
+            // remember referenced object's file, see GetFileNameFromNode()
+            copy.AddAttribute(ATTR_INPUT_FILENAME,
+                              GetFileNameFromNode(refNode, Data()));
 
-        return CreateResFromNode(&copy, parent, instance);
+            return CreateResFromNode(&copy, parent, instance);
+        }
     }
 
     if (handlerToUse)