diff --git a/src/olympic/studio/applib/src/clawviewer.cpp b/src/olympic/studio/applib/src/clawviewer.cpp index 861a04b0..89a61b7d 100644 --- a/src/olympic/studio/applib/src/clawviewer.cpp +++ b/src/olympic/studio/applib/src/clawviewer.cpp @@ -8,12 +8,12 @@ namespace studio { -ClawEditor::ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept: - Editor(path), - m_obj(std::move(obj)) { +ClawEditor::ClawEditor(StudioContext &sctx, ox::StringParam path): + Editor(std::move(path)), + m_obj(sctx.project->loadObj(itemPath()).unwrapThrow()) { } -void ClawEditor::draw(studio::StudioContext&) noexcept { +void ClawEditor::draw(StudioContext&) noexcept { ImGui::BeginChild("PaletteEditor"); static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody; if (ImGui::BeginTable("ObjTree", 3, flags)) { diff --git a/src/olympic/studio/applib/src/clawviewer.hpp b/src/olympic/studio/applib/src/clawviewer.hpp index 5441ac30..1b201f5c 100644 --- a/src/olympic/studio/applib/src/clawviewer.hpp +++ b/src/olympic/studio/applib/src/clawviewer.hpp @@ -11,14 +11,14 @@ namespace studio { -class ClawEditor: public studio::Editor { +class ClawEditor: public Editor { private: using ObjPath = ox::Vector; ox::ModelObject m_obj; public: - ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept; + ClawEditor(StudioContext &sctx, ox::StringParam path); - void draw(studio::StudioContext&) noexcept final; + void draw(StudioContext&) noexcept final; private: static void drawRow(ox::ModelValue const&value) noexcept; diff --git a/src/olympic/studio/applib/src/studioapp.cpp b/src/olympic/studio/applib/src/studioapp.cpp index db84e5a3..e54e1167 100644 --- a/src/olympic/studio/applib/src/studioapp.cpp +++ b/src/olympic/studio/applib/src/studioapp.cpp @@ -366,23 +366,17 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) } oxRequire(ext, studio::fileExt(path)); // create Editor - studio::BaseEditor *editor = nullptr; - if (!m_editorMakers.contains(ext)) { - auto [obj, err] = m_project->loadObj(path); - if (err) { - return OxError(1, "There is no editor for this file extension"); - } - editor = ox::make(path, std::move(obj)); - } else { - auto const err = m_editorMakers[ext](path).moveTo(editor); - if (err) { - if constexpr(!ox::defines::Debug) { - oxErrf("Could not open Editor: {}\n", toStr(err)); - } else { - oxErrf("Could not open Editor: {} ({}:{})\n", err.errCode, err.file, err.line); - } - return err; + BaseEditor *editor = nullptr; + auto const err = m_editorMakers.contains(ext) ? + m_editorMakers[ext](path).moveTo(editor) : + ox::makeCatch(m_sctx, path).moveTo(editor); + if (err) { + if constexpr(!ox::defines::Debug) { + oxErrf("Could not open Editor: {}\n", toStr(err)); + } else { + oxErrf("Could not open Editor: {} ({}:{})\n", err.errCode, err.file, err.line); } + return err; } editor->closed.connect(this, &StudioUI::closeFile); m_editors.emplace_back(editor);