From 425ece48601d81fabafe814dce4c111ec8ec264c Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 12 Apr 2023 09:42:10 +0800 Subject: [PATCH] fix: The data be cleaned before switch new device --- DSView/pv/mainwindow.cpp | 27 ++++++++++++++++++++++++--- DSView/pv/mainwindow.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index eb7bd473..8aebd7d8 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -114,6 +114,7 @@ namespace pv _session->add_msg_listener(this); _is_auto_switch_device = false; + _is_save_confirm_msg = false; setup_ui(); @@ -1486,13 +1487,26 @@ namespace pv } bool MainWindow::confirm_to_store_data() - { + { + bool ret = false; + _is_save_confirm_msg = true; + if (_session->have_hardware_data() && _session->is_first_store_confirm()) { // Only popup one time. - return MsgBox::Confirm(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SAVE_CAPDATE), "Save captured data?")); + ret = MsgBox::Confirm(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SAVE_CAPDATE), "Save captured data?")); + + if (!ret && _is_auto_switch_device) + { + dsv_info("The data save confirm end, auto switch to the new device."); + _is_auto_switch_device = false; + _session->set_default_device(); + check_usb_device_speed(); + } } - return false; + + _is_save_confirm_msg = false; + return ret; } void MainWindow::check_session_file_version() @@ -1743,6 +1757,13 @@ namespace pv } } + // The store confirm is not processed. + if (_is_save_confirm_msg){ + _is_auto_switch_device = true; + _sampling_bar->update_device_list(); + return; + } + if (confirm_to_store_data()) { _is_auto_switch_device = true; diff --git a/DSView/pv/mainwindow.h b/DSView/pv/mainwindow.h index a481c26b..7b7ea75c 100644 --- a/DSView/pv/mainwindow.h +++ b/DSView/pv/mainwindow.h @@ -213,6 +213,7 @@ private: DeviceAgent *_device_agent; bool _is_auto_switch_device; high_resolution_clock::time_point _last_key_press_time; + bool _is_save_confirm_msg; int _key_value; bool _key_vaild;