critical fix

This commit is contained in:
MihailRis 2024-03-20 19:09:50 +03:00
parent 6f351e2b79
commit e5fb9a9a23

View File

@ -62,9 +62,11 @@ std::unique_ptr<UiDocument> UiDocument::read(int penv, std::string namesp, fs::p
const std::string text = files::read_string(file);
auto xmldoc = xml::parse(file.u8string(), text);
auto env = penv == -1 ? nullptr : scripting::create_doc_environment(penv, namesp);
scripting::Environment envview {penv == -1 ? 0 : env->getId()};
gui::UiXmlReader reader(envview);
auto env = penv == -1
? std::make_unique<scripting::Environment>(0)
: scripting::create_doc_environment(penv, namesp);
gui::UiXmlReader reader(*env);
InventoryView::createReaders(reader);
auto view = reader.readXML(
file.u8string(), xmldoc->getRoot()
@ -73,9 +75,9 @@ std::unique_ptr<UiDocument> UiDocument::read(int penv, std::string namesp, fs::p
uidocscript script {};
auto scriptFile = fs::path(file.u8string()+".lua");
if (fs::is_regular_file(scriptFile)) {
scripting::load_layout_script(envview.getId(), namesp, scriptFile, script);
scripting::load_layout_script(env->getId(), namesp, scriptFile, script);
}
return std::make_unique<UiDocument>(namesp, script, view, penv == -1 ? nullptr : std::move(env));
return std::make_unique<UiDocument>(namesp, script, view, std::move(env));
}
std::shared_ptr<gui::UINode> UiDocument::readElement(fs::path file) {