From 8dc405f72984ee054d32e5fe2a7c1b0314a7ca23 Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Thu, 12 Jul 2012 17:44:26 -0400 Subject: [PATCH] desktop: fixed inconsistency between multiple device renames It is possible to rename the device in 3 places: the Desktop main menu, the Sync config dialog, and the BarryBackup GUI config dialog. If the device is renamed in the external GUI application, then the devices need to be re-probed after the GUI exits to maintain consistency. --- desktop/src/BaseFrame.cc | 21 +++++++++++++++++++-- desktop/src/BaseFrame.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/desktop/src/BaseFrame.cc b/desktop/src/BaseFrame.cc index 224890d5..14b30c3b 100644 --- a/desktop/src/BaseFrame.cc +++ b/desktop/src/BaseFrame.cc @@ -80,6 +80,7 @@ BaseFrame::BaseFrame(const wxImage &background) , m_height(background.GetHeight()) , m_current_mode(0) , m_backup_process(this) + , m_rescan_pending(false) { // This is a workaround for different size behaviour // in the GTK version of wxWidgets 2.9 @@ -244,6 +245,12 @@ void BaseFrame::DisableBackButton() // reset the current mode to main menu and repaint m_current_mode = m_main_menu_mode.get(); Refresh(false); + + // if a USB rescan is pending, do it now + if( m_rescan_pending ) { + wxCommandEvent event; + OnRescanUsb(event); + } } void BaseFrame::OnSize(wxSizeEvent &event) @@ -732,6 +739,14 @@ void BaseFrame::OnTermBackupAndRestore(wxProcessEvent &event) wxMessageBox(_T("Unable to run barrybackup, or it returned an error. Please make sure it is installed and in your PATH."), _T("Backup and Restore"), wxOK | wxICON_ERROR); } + else + { + // looks like a successful run... the device name may + // have been changed by the BarryBackup GUI, so reprobe + // to refresh the names and device list + wxCommandEvent event; + OnRescanUsb(event); + } } void BaseFrame::OnBarryLogoClicked(wxCommandEvent &event) @@ -824,10 +839,12 @@ void BaseFrame::OnRescanUsb(wxCommandEvent &event) std::auto_ptr splash( new UsbScanSplash ); wxGetApp().Probe(); CreateDeviceCombo(wxGetApp().GetGlobalConfig().GetLastDevice()); + m_rescan_pending = false; } else { - // FIXME - tell the user we didn't do anything? - // or perhaps just disable rescan while in a mode + // flag that we need to rescan the next time we return + // to the main screen + m_rescan_pending = true; } } diff --git a/desktop/src/BaseFrame.h b/desktop/src/BaseFrame.h index ceb6abf2..02b1d24d 100644 --- a/desktop/src/BaseFrame.h +++ b/desktop/src/BaseFrame.h @@ -57,6 +57,8 @@ private: ExecHelper m_backup_process; + bool m_rescan_pending; + public: BaseFrame(const wxImage &background); -- 2.11.4.GIT