diff options
author | ConfuSomu | 2024-01-26 11:21:00 -0500 |
---|---|---|
committer | ConfuSomu | 2024-01-26 11:21:00 -0500 |
commit | d561873e43de73b5ed48367bed6b6fcdfdefc174 (patch) | |
tree | e6e7c09eaa8ac2f9f688e9488756e0cfdf008439 /src/mainwindow.cpp | |
parent | 803432b3907ac8934263b0317a756ffbe8549db1 (diff) | |
download | ActorViewer-d561873e43de73b5ed48367bed6b6fcdfdefc174.tar ActorViewer-d561873e43de73b5ed48367bed6b6fcdfdefc174.tar.gz ActorViewer-d561873e43de73b5ed48367bed6b6fcdfdefc174.zip |
Clear Activity list when invalid archive opened
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1432116..16686c4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -50,8 +50,11 @@ void MainWindow::create_initial_tabs() { connect(ui->actionFind, &QAction::triggered, activity_list_tab, &TabActivityList::on_buttonSearch_clicked); connect(ui->actionOpen_URL, &QAction::triggered, activity_list_tab, &TabActivityList::actionOpen_URL_triggered); connect(ui->menuView, &QMenu::aboutToHide, activity_list_tab, &TabActivityList::menuView_aboutToHide); - connect(this, &MainWindow::new_archive_opened, activity_list_tab, [=] { - activity_list_tab->relist_statuses(true); + connect(this, &MainWindow::new_archive_opened, activity_list_tab, [=](bool is_valid) { + if (is_valid) + activity_list_tab->relist_statuses(true); + else + activity_list_tab->clear_list(); }); // TODO: maybe have one Actor info tab that is constantly updated with the new opened archive? @@ -153,9 +156,13 @@ void MainWindow::finish_open_file(const Archive::InitError& parse_error) { break; } - if (parse_error == Archive::NoError) { - emit new_archive_opened(); + // Avoids errors elsewhere down the line + if (parse_error != Archive::NoError) { + delete data_archive; + data_archive = nullptr; } + emit new_archive_opened(parse_error == Archive::NoError); + actor_info_tab = new TabActorInfo(data_archive); ui->tabWidget->addTab(actor_info_tab, tr("Actor Info")); connect(this, &MainWindow::new_archive_opened, actor_info_tab, &TabActorInfo::deleteLater); |