diff --git a/src/legacy_document_open_services.cpp b/src/legacy_document_open_services.cpp index a7d763ab..344f0470 100644 --- a/src/legacy_document_open_services.cpp +++ b/src/legacy_document_open_services.cpp @@ -38,24 +38,33 @@ pp::foundation::Status apply_document_history(const pp::app::HistoryUiPlan& plan return pp::app::execute_history_ui_plan(plan, services); } +void refresh_opened_legacy_project_layers(App& app) +{ + app.title_update(); + for (std::size_t layer_index = 0; layer_index < app.canvas->m_canvas->m_layers.size(); ++layer_index) + { + auto layer = app.layers->add_layer(app.canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false); + layer->m_visibility->set_value(app.canvas->m_canvas->m_layers[layer_index]->m_visible); + } +} + +void show_open_legacy_project_error(App& app) +{ + app.message_box( + "Open Document Error", + "There was an error opening the document.\n" + "It may be inaccessible or corrupted."); +} + void handle_open_legacy_project_result(App& app, bool success) { if (success) { - app.title_update(); - for (std::size_t layer_index = 0; layer_index < app.canvas->m_canvas->m_layers.size(); ++layer_index) - { - auto layer = app.layers->add_layer(app.canvas->m_canvas->m_layers[layer_index]->m_name.c_str(), false); - layer->m_visibility->set_value(app.canvas->m_canvas->m_layers[layer_index]->m_visible); - } - } - else - { - app.message_box( - "Open Document Error", - "There was an error opening the document.\n" - "It may be inaccessible or corrupted."); + refresh_opened_legacy_project_layers(app); + return; } + + show_open_legacy_project_error(app); } void open_legacy_project(App& app, const pp::app::DocumentOpenRoute& route)