[nostalgia/studio] Fix closing last tab

This commit is contained in:
Gary Talent 2021-11-29 03:37:22 -06:00
parent a94051644b
commit 6e8bb8adc6

View File

@ -140,7 +140,8 @@ void StudioUI::drawTabs() noexcept {
ImGui::Begin("TabWindow##MainWindow", nullptr, windowFlags);
constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton;
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow", tabBarFlags)) {
for (auto &e : m_editors) {
for (auto it = m_editors.begin(); it != m_editors.end(); ) {
auto const &e = *it;
bool open = true;
if (ImGui::BeginTabItem(e->itemDisplayName().c_str(), &open)) {
e->draw(m_ctx);
@ -149,10 +150,14 @@ void StudioUI::drawTabs() noexcept {
if (!open) {
e->close();
try {
oxThrowError(m_editors.erase(e));
} catch (const std::exception &e) {
oxErrf("Editor tab deletion failed: {}", e.what());
oxThrowError(m_editors.erase(it).moveTo(&it));
} catch (const ox::Exception &ex) {
oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line);
} catch (const std::exception &ex) {
oxErrf("Editor tab deletion failed: {}\n", ex.what());
}
} else {
++it;
}
}
ImGui::EndTabBar();
@ -173,10 +178,10 @@ void StudioUI::loadModule(studio::Module *module) noexcept {
}
void StudioUI::loadModules() noexcept {
//for (auto &moduleMaker : BuiltinModules) {
// const auto module = moduleMaker();
// loadModule(module.get());
//}
for (auto &moduleMaker : BuiltinModules) {
const auto module = moduleMaker();
loadModule(module.get());
}
}
ox::Error StudioUI::openProject(const ox::String &path) noexcept {