Fix crash when attempting to add VPN connection when VPN service is not available

pull/1/head
Timothy Pearson 11 years ago
parent f62332d1fb
commit bb5795c1b5

@ -31,6 +31,7 @@
#include <tqcombobox.h> #include <tqcombobox.h>
#include <tqiconset.h> #include <tqiconset.h>
#include <kiconloader.h> #include <kiconloader.h>
#include <kpushbutton.h>
#include <tqwidgetstack.h> #include <tqwidgetstack.h>
#include <kuser.h> #include <kuser.h>
@ -46,6 +47,7 @@ VPNWidgetImpl::VPNWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget
, _new_conn(new_conn) , _new_conn(new_conn)
{ {
_vpnsetting = dynamic_cast<TDEVPNConnection*>(conn); _vpnsetting = dynamic_cast<TDEVPNConnection*>(conn);
_parentdialog = dynamic_cast<ConnectionSettingsDialogImpl*>(parent);
TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1);
_mainWid = new ConnectionSettingVPNWidget(this); _mainWid = new ConnectionSettingVPNWidget(this);
@ -61,7 +63,10 @@ VPNWidgetImpl::Init()
VPNServiceList list = VPNManager::getVPNServices(); VPNServiceList list = VPNManager::getVPNServices();
if (list.isEmpty()) { if (list.isEmpty()) {
// FIXME Do something useful here if (_parentdialog) {
_parentdialog->_disable_next_button = true;
_parentdialog->slotEnableButtons();
}
} }
else { else {
int index = 0; int index = 0;
@ -108,6 +113,10 @@ VPNWidgetImpl::Init()
slotServiceComboActivated(index - 1); slotServiceComboActivated(index - 1);
} }
} }
if (_parentdialog) {
_parentdialog->_disable_next_button = false;
_parentdialog->slotEnableButtons();
}
} }
// lock the combo when editing an already existing connection // lock the combo when editing an already existing connection

@ -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) ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection* conn, bool new_conn, TQByteArray networkextid, TQWidget* parent, const char* name, bool modal, WFlags fl)
: ConnectionSettingsDialog(parent, name, modal, fl) : ConnectionSettingsDialog(parent, name, modal, fl)
, _disable_next_button(false)
, _conn(conn) , _conn(conn)
, _new_conn(new_conn) , _new_conn(new_conn)
, _networkextid(networkextid) , _networkextid(networkextid)
@ -78,7 +79,7 @@ ConnectionSettingsDialogImpl::ConnectionSettingsDialogImpl(TDENetworkConnection*
pbCancel->setIconSet(SmallIcon("cancel", TQIconSet::Automatic)); pbCancel->setIconSet(SmallIcon("cancel", TQIconSet::Automatic));
pbSave->setIconSet(SmallIcon("ok", 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(); slotEnableButtons();
} }
@ -430,13 +431,13 @@ ConnectionSettingsDialogImpl::slotEnableButtons()
Next: enabled if another widget is available Next: enabled if another widget is available
*/ */
enabled = true; enabled = true;
if (current == _widgetIds.fromLast()) { if (current == _widgetIds.fromLast() || _disable_next_button) {
enabled = false; enabled = false;
} }
pbNext->setEnabled(enabled); pbNext->setEnabled(enabled);
/* /*
Back: enabled if the current widget has a predecessor Back: enabled if the current widget has a predecessor
*/ */
enabled = true; enabled = true;
if (current == _widgetIds.begin()) { if (current == _widgetIds.begin()) {
@ -445,7 +446,7 @@ ConnectionSettingsDialogImpl::slotEnableButtons()
pbBack->setEnabled(enabled); pbBack->setEnabled(enabled);
/* /*
Connect: only show connect if the connection is valid Connect: only show connect if the connection is valid
*/ */
if (_conn) { if (_conn) {
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager(); TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();

@ -64,6 +64,9 @@ class ConnectionSettingsDialogImpl : public ConnectionSettingsDialog
signals: signals:
void connectionSaved(); void connectionSaved();
public:
bool _disable_next_button;
private: private:
void updateDialogForDeviceType(); void updateDialogForDeviceType();
void createWidgetsForConnection(TDENetworkConnection*, bool new_conn); void createWidgetsForConnection(TDENetworkConnection*, bool new_conn);

Loading…
Cancel
Save