diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index da63292d..a5a04a7a 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -155,10 +155,11 @@ void LanPage::initNetSwitch() m_switchGsettings->set(WIRED_SWITCH, wiredEnable); } - bool oldState; - if (getOldWiredSwitchState(oldState)) { - if (wiredEnable != oldState) { - m_wiredConnectOperation->setWiredEnabled(oldState); + //从3.0升级上来 先读取老的配置文件来保证和升级前状态一致 + bool oldVersionState; + if (getOldVersionWiredSwitchState(oldVersionState)) { + if (wiredEnable != oldVersionState) { + m_wiredConnectOperation->setWiredEnabled(oldVersionState); } } diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index d5a9a856..342e8f67 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -302,15 +302,19 @@ void getDeviceEnableState(int type, QMap &map) kdr = nullptr; } -bool getOldWiredSwitchState(bool state) +bool getOldVersionWiredSwitchState(bool state) { QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); QVariant value = m_settings->value("lan_switch_opened"); - if (!value.isValid()) + if (!value.isValid()) { + delete m_settings; + m_settings = nullptr; return false; + } state = value.toBool(); m_settings->remove("lan_switch_opened"); delete m_settings; + m_settings = nullptr; return true; } diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index 5bdd8d25..97a981df 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -81,7 +81,7 @@ bool checkDeviceExist(KyDeviceType deviceType, QString deviceName); QString getDefaultDeviceName(KyDeviceType deviceType); void setDefaultDevice(KyDeviceType deviceType, QString deviceName); void getDeviceEnableState(int type, QMap &map); -bool getOldWiredSwitchState(bool state); +bool getOldVersionWiredSwitchState(bool state); class TabPage : public QWidget {