App doesn't crash when attempting to open bad file through double click
This commit is contained in:
parent
354c6e4cdc
commit
12bb936c16
5 changed files with 11 additions and 15 deletions
|
|
@ -361,7 +361,6 @@ void MainProgram::set_tab_to_close(World* world) {
|
||||||
|
|
||||||
void MainProgram::switch_to_tab(size_t wIndex) {
|
void MainProgram::switch_to_tab(size_t wIndex) {
|
||||||
world = worlds[wIndex];
|
world = worlds[wIndex];
|
||||||
worldIndex = wIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainProgram::post_callback() {
|
void MainProgram::post_callback() {
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,6 @@ class MainProgram {
|
||||||
|
|
||||||
bool drawGui = true;
|
bool drawGui = true;
|
||||||
|
|
||||||
size_t worldIndex = 0;
|
|
||||||
std::shared_ptr<World> world;
|
std::shared_ptr<World> world;
|
||||||
std::vector<std::shared_ptr<World>> worlds;
|
std::vector<std::shared_ptr<World>> worlds;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,7 @@ void DesktopDrawingProgramScreen::on_tab_close() {
|
||||||
main.create_new_tab({
|
main.create_new_tab({
|
||||||
.isClient = false
|
.isClient = false
|
||||||
});
|
});
|
||||||
else if(main.world)
|
else if(!main.world)
|
||||||
main.worldIndex = std::find(main.worlds.begin(), main.worlds.end(), main.world) - main.worlds.begin();
|
|
||||||
else
|
|
||||||
main.switch_to_tab(0);
|
main.switch_to_tab(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -445,9 +445,11 @@ void Toolbar::top_toolbar() {
|
||||||
tabNames.emplace_back(w->netObjMan.is_connected() ? "data/icons/network.svg" : "", w->name + (shouldAddStarNextToName ? "*" : ""));
|
tabNames.emplace_back(w->netObjMan.is_connected() ? "data/icons/network.svg" : "", w->name + (shouldAddStarNextToName ? "*" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t worldIndex = std::find(main.worlds.begin(), main.worlds.end(), main.world) - main.worlds.begin();
|
||||||
|
|
||||||
gui.element<MovableTabList>("file tab list", MovableTabListData{
|
gui.element<MovableTabList>("file tab list", MovableTabListData{
|
||||||
.tabNames = tabNames,
|
.tabNames = tabNames,
|
||||||
.selectedTab = main.worldIndex,
|
.selectedTab = worldIndex,
|
||||||
.changeSelectedTab = [&] (size_t i) {
|
.changeSelectedTab = [&] (size_t i) {
|
||||||
main.switch_to_tab(i);
|
main.switch_to_tab(i);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
10
src/main.cpp
10
src/main.cpp
|
|
@ -560,18 +560,16 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
mS.m->set_first_screen(std::make_unique<FileSelectScreen>(*mS.m));
|
mS.m->set_first_screen(std::make_unique<FileSelectScreen>(*mS.m));
|
||||||
else {
|
else {
|
||||||
mS.m->set_first_screen(std::make_unique<DesktopDrawingProgramScreen>(*mS.m));
|
mS.m->set_first_screen(std::make_unique<DesktopDrawingProgramScreen>(*mS.m));
|
||||||
if(listOfFilesToOpenFromCommand.empty()) {
|
|
||||||
mS.m->create_new_tab({
|
|
||||||
.isClient = false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(std::filesystem::path& f : listOfFilesToOpenFromCommand) {
|
for(std::filesystem::path& f : listOfFilesToOpenFromCommand) {
|
||||||
mS.m->create_new_tab({
|
mS.m->create_new_tab({
|
||||||
.isClient = false,
|
.isClient = false,
|
||||||
.filePathSource = f
|
.filePathSource = f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if(mS.m->worlds.empty()) {
|
||||||
|
mS.m->create_new_tab({
|
||||||
|
.isClient = false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue