2
0
aquawicket2 5 жил өмнө
parent
commit
986af0ab38

+ 3 - 4
Include/RmlUi/Core/Context.h

@@ -88,10 +88,9 @@ public:
 	bool Render();
 
 	/// Creates a new, empty document and places it into this context.
-	/// @param[in] tag The document type to create.
+	/// @param[in] instancer_name The name of the instancer used to create the document.
 	/// @return The new document, or nullptr if no document could be created.
-	// FIXME - tag parameter should be named instancer_name, it references to instancer_name in InstanceElement(), not the tag name.
-	ElementDocument* CreateDocument(const String& tag = "body");
+	ElementDocument* CreateDocument(const String& instancer_name = "body");
 	/// Load a document into the context.
 	/// @param[in] document_path The path to the document to load.
 	/// @return The loaded document, or nullptr if no document was loaded.
@@ -246,7 +245,7 @@ public:
 
 	/// Gets the name of the documents base tag.
 	/// @return The current documents base tag name.
-	String GetDocumentsBaseTag();
+	const String& GetDocumentsBaseTag();
 
 protected:
 	void Release() override;

+ 5 - 6
Source/Core/Context.cpp

@@ -214,21 +214,20 @@ bool Context::Render()
 	return true;
 }
 
-// FIXME - tag parameter should be named instancer_name, it references to instancer_name in InstanceElement(), not the tag name.
 // Creates a new, empty document and places it into this context. 
-ElementDocument* Context::CreateDocument(const String& tag)
+ElementDocument* Context::CreateDocument(const String& instancer_name)
 {
-	ElementPtr element = Factory::InstanceElement(nullptr, tag, documents_base_tag, XMLAttributes());
+	ElementPtr element = Factory::InstanceElement(nullptr, instancer_name, documents_base_tag, XMLAttributes());
 	if (!element)
 	{
-		Log::Message(Log::LT_ERROR, "Failed to instance document on tag '%s', instancer returned nullptr.", tag.c_str());
+		Log::Message(Log::LT_ERROR, "Failed to instance document on instancer_name '%s', instancer returned nullptr.", instancer_name.c_str());
 		return nullptr;
 	}
 
 	ElementDocument* document = rmlui_dynamic_cast< ElementDocument* >(element.get());
 	if (!document)
 	{
-		Log::Message(Log::LT_ERROR, "Failed to instance document on tag '%s', Found type '%s', was expecting derivative of ElementDocument.", tag.c_str(), rmlui_type_name(*element));
+		Log::Message(Log::LT_ERROR, "Failed to instance document on instancer_name '%s', Found type '%s', was expecting derivative of ElementDocument.", instancer_name.c_str(), rmlui_type_name(*element));
 		return nullptr;
 	}
 
@@ -1304,7 +1303,7 @@ void Context::SetDocumentsBaseTag(const String& tag)
 	documents_base_tag = tag;
 }
 
-String Context::GetDocumentsBaseTag()
+const String& Context::GetDocumentsBaseTag()
 {
 	return documents_base_tag;
 }

+ 1 - 0
Source/Core/Factory.cpp

@@ -467,6 +467,7 @@ bool Factory::InstanceElementStream(Element* parent, Stream* stream)
 ElementPtr Factory::InstanceDocumentStream(Context* context, Stream* stream)
 {
 	RMLUI_ZoneScoped;
+	RMLUI_ASSERT(context);
 
 	ElementPtr element = Factory::InstanceElement(nullptr, context->GetDocumentsBaseTag(), context->GetDocumentsBaseTag(), XMLAttributes());
 	if (!element)