fix: The data be cleaned before switch new device

This commit is contained in:
dreamsourcelabTAI 2023-04-12 09:42:10 +08:00
parent 7bd24cc1b6
commit 425ece4860
2 changed files with 25 additions and 3 deletions

View File

@ -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;

View File

@ -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;