| 338 | } |
| 339 | |
| 340 | void MainProgram::create_new_tab(const CustomEvents::OpenInfiniPaintFileEvent& openFile) { |
| 341 | std::shared_ptr<World> newWorld; |
| 342 | try { |
| 343 | newWorld = std::make_shared<World>(*this, openFile); |
| 344 | } |
| 345 | catch(const std::runtime_error& e) { |
| 346 | #ifdef __ANDROID__ |
| 347 | Logger::get().log(Logger::LogType::WORLDFATAL, std::string("Failed to open canvas: ") + e.what()); |
| 348 | #else |
| 349 | Logger::get().log(Logger::LogType::WORLDFATAL, "Failed to open canvas: " + (openFile.filePathSource.has_value() ? openFile.filePathSource.value().string() : "NO PATH") + " with error: " + e.what()); |
| 350 | #endif |
| 351 | return; |
| 352 | } |
| 353 | worlds.emplace_back(newWorld); |
| 354 | switch_to_tab(worlds.size() - 1); |
| 355 | g.gui.set_to_layout(); |
| 356 | } |
| 357 | |
| 358 | void MainProgram::set_tab_to_close(World* world) { |
| 359 | tabsToClose.emplace(world); |
no test coverage detected