From bb5795c1b5445afac3645d7ccec240c4e3f4128a Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 18 May 2013 21:48:50 -0500 Subject: [PATCH] Fix crash when attempting to add VPN connection when VPN service is not available --- .../tdenetman-connection_setting_vpn_widget.cpp | 11 ++++++++++- .../tdenetman-connection_settings_dialog.cpp | 9 +++++---- .../tdenetman-connection_settings_dialog.h | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp index 36140d8..ec2ce50 100644 --- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,7 @@ VPNWidgetImpl::VPNWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget , _new_conn(new_conn) { _vpnsetting = dynamic_cast(conn); + _parentdialog = dynamic_cast(parent); TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); _mainWid = new ConnectionSettingVPNWidget(this); @@ -61,7 +63,10 @@ VPNWidgetImpl::Init() VPNServiceList list = VPNManager::getVPNServices(); if (list.isEmpty()) { - // FIXME Do something useful here + if (_parentdialog) { + _parentdialog->_disable_next_button = true; + _parentdialog->slotEnableButtons(); + } } else { int index = 0; @@ -108,6 +113,10 @@ VPNWidgetImpl::Init() slotServiceComboActivated(index - 1); } } + if (_parentdialog) { + _parentdialog->_disable_next_button = false; + _parentdialog->slotEnableButtons(); + } } // lock the combo when editing an already existing connection diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp index d60fe9b..9cb8b46 100644 --- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp @@ -58,6 +58,7 @@ using namespace ConnectionSettings; ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQByteArray networkextid, TQWidget* parent, const char* name, bool modal, WFlags fl) : ConnectionSettingsDialog(parent, name, modal, fl) + , _disable_next_button(false) , _conn(conn) , _new_conn(new_conn) , _networkextid(networkextid) @@ -78,7 +79,7 @@ ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* pbCancel->setIconSet(SmallIcon("cancel", TQIconSet::Automatic)); pbSave->setIconSet(SmallIcon("ok", TQIconSet::Automatic)); - // enable or disable buttons accroding to the current state + // enable or disable buttons according to the current state slotEnableButtons(); } @@ -430,13 +431,13 @@ ConnectionSettingsDialogImpl::slotEnableButtons() Next: enabled if another widget is available */ enabled = true; - if (current == _widgetIds.fromLast()) { + if (current == _widgetIds.fromLast() || _disable_next_button) { enabled = false; } pbNext->setEnabled(enabled); /* - Back: enabled if the current widget has a predecessor + Back: enabled if the current widget has a predecessor */ enabled = true; if (current == _widgetIds.begin()) { @@ -445,7 +446,7 @@ ConnectionSettingsDialogImpl::slotEnableButtons() pbBack->setEnabled(enabled); /* - Connect: only show connect if the connection is valid + Connect: only show connect if the connection is valid */ if (_conn) { TDEGlobalNetworkManager* nm = TDEGlobal::networkManager(); diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h index b9f54f1..51e4b6c 100644 --- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h +++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.h @@ -64,6 +64,9 @@ class ConnectionSettingsDialogImpl : public ConnectionSettingsDialog signals: void connectionSaved(); + public: + bool _disable_next_button; + private: void updateDialogForDeviceType(); void createWidgetsForConnection(TDENetworkConnection*, bool new_conn);