diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 15 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/widgets/tab_activity_list.cpp | 4 | ||||
-rw-r--r-- | src/widgets/tab_activity_list.h | 1 | ||||
-rw-r--r-- | src/widgets/tab_actor_info.cpp | 5 |
5 files changed, 19 insertions, 8 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); diff --git a/src/mainwindow.h b/src/mainwindow.h index aadd439..cc43176 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -32,7 +32,7 @@ public slots: signals: void search_text_changed(const QString &text, bool search_immediately = false); - void new_archive_opened(); + void new_archive_opened(bool is_valid); private slots: void on_actionOpen_triggered(bool checked); diff --git a/src/widgets/tab_activity_list.cpp b/src/widgets/tab_activity_list.cpp index 63d6fbf..dd40de7 100644 --- a/src/widgets/tab_activity_list.cpp +++ b/src/widgets/tab_activity_list.cpp @@ -118,6 +118,10 @@ void TabActivityList::relist_statuses(bool new_archive_opened) { } } +void TabActivityList::clear_list() { + ui->listWidget->clear(); +} + // Function used to reset filters when we have detected that the "All toots" toggle has been toggled on or shouldn't be toggled anymore void TabActivityList::reset_view_filters() { if (view_actions.actionAll_toots->isChecked()) diff --git a/src/widgets/tab_activity_list.h b/src/widgets/tab_activity_list.h index 4e520da..3e86f32 100644 --- a/src/widgets/tab_activity_list.h +++ b/src/widgets/tab_activity_list.h @@ -42,6 +42,7 @@ public slots: void menuView_aboutToHide(); void relist_statuses(bool new_archive_opened = false); + void clear_list(); void select_list_item(QListWidgetItem* item); void set_search_text(const QString &text); diff --git a/src/widgets/tab_actor_info.cpp b/src/widgets/tab_actor_info.cpp index 341522d..f991366 100644 --- a/src/widgets/tab_actor_info.cpp +++ b/src/widgets/tab_actor_info.cpp @@ -3,7 +3,6 @@ #include "src/activitypub/apactor.h" #include "src/archive/base_archive.h" #include <QTableWidgetItem> -#include <QDebug> TabActorInfo::TabActorInfo(APActor* actor, QWidget* parent) : QWidget(parent), ui(new Ui::TabActorInfo), actor(actor) @@ -20,8 +19,8 @@ TabActorInfo::TabActorInfo(Archive* archive, QWidget* parent) ui->setupUi(this); ui->gridLayout->setContentsMargins(0, 0, 0, 0); - actor = archive->get_main_actor(); - qDebug() << actor; + if (archive) + actor = archive->get_main_actor(); update_ui(); } |