From 61b049d8dce3560b4889a9856efbaf7f87ce4bcd Mon Sep 17 00:00:00 2001 From: uncor3 Date: Fri, 20 Mar 2026 03:10:35 +0000 Subject: [PATCH] feat: add close event handling to MainWindow for active processes --- src/mainwindow.cpp | 34 ++++++++++++++++++++++++++-------- src/mainwindow.h | 3 +++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f6656ad..809242a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -497,16 +497,34 @@ void MainWindow::updateNoDevicesConnected() m_mainStackedWidget->setCurrentIndex(1); // Show device list page } +void MainWindow::closeEvent(QCloseEvent *event) +{ + if (StatusBalloon::sharedInstance()->hasActiveProcesses()) { + auto reply = QMessageBox::question( + this, tr("Transfers in Progress"), + tr("There are import/export operations in progress.\n" + "Do you really want to quit? This will cancel them."), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + + if (reply == QMessageBox::No) { + event->ignore(); + return; + } + + ExportManager::sharedInstance()->cancelAllJobs(); + } + + QMainWindow::closeEvent(event); +} + MainWindow::~MainWindow() { - // idevice_event_unsubscribe(); - // #ifdef ENABLE_RECOVERY_DEVICE_SUPPORT - // irecv_device_event_unsubscribe(context); - // #endif +#ifdef ENABLE_RECOVERY_DEVICE_SUPPORT + irecv_device_event_unsubscribe(context); +#endif m_deviceMonitor->requestInterruption(); - // FIXME:QThread: Destroyed while thread '' is still running - // m_deviceMonitor->wait(); + m_deviceMonitor->wait(); delete m_deviceMonitor; - // delete m_updater; + delete m_updater; // sleep(2); -} +} \ No newline at end of file diff --git a/src/mainwindow.h b/src/mainwindow.h index 8f23da0..d52fc28 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -56,5 +56,8 @@ private: QWidget *m_titleBar; QWidget *m_contentArea; QHBoxLayout *m_titleBarLayout; + +protected: + void closeEvent(QCloseEvent *event) override; }; #endif // MAINWINDOW_H