From 023236bba0e9ce74f59238391e76d8d99b6619bf Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Wed, 23 May 2012 02:18:01 -0400 Subject: [PATCH] desktop: fixed bug that deleted device name if saving an unconnected sync cfg When viewing sync devices in the sync window, it shows devices, even if they are not currently connected via USB. If the user edited a particular sync config while the device was disconnected, the wrong source of device name was used, and the empty string was written back to the config file. --- desktop/src/GroupCfgDlg.cc | 5 ++++- desktop/src/barrydesktop.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/desktop/src/GroupCfgDlg.cc b/desktop/src/GroupCfgDlg.cc index 2078237e..38d48fc1 100644 --- a/desktop/src/GroupCfgDlg.cc +++ b/desktop/src/GroupCfgDlg.cc @@ -374,7 +374,10 @@ void GroupCfgDlg::LoadBarryConfig() { Config::Barry &bp = m_barry_plugin; - wxString dname(wxGetApp().GetDeviceName(bp.GetPin()).c_str(), wxConvUTF8); + // use m_device here, since BarryDesktopApp::GetDeviceName() + // may return an empty string if the device is not currently + // plugged in + wxString dname(m_device.GetDeviceName().c_str(), wxConvUTF8); m_name_edit->SetValue(dname); m_password_edit->SetValue(wxString(bp.GetPassword().c_str(), wxConvUTF8)); diff --git a/desktop/src/barrydesktop.h b/desktop/src/barrydesktop.h index dfeed492..f5550b14 100644 --- a/desktop/src/barrydesktop.h +++ b/desktop/src/barrydesktop.h @@ -75,6 +75,11 @@ public: /// m_results entry will be updated with the new device name, /// so the next GetResults() will contain the new name. void SetDeviceName(Barry::Pin pin, const std::string &name); + + /// Returns device name for the given PIN, but ONLY if the + /// device is connected. If you want to read the device + /// name of an unconnected device, use DeviceSet or just + /// load the config manually with Barry::ConfigFile. std::string GetDeviceName(Barry::Pin pin) const; // -- 2.11.4.GIT