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

pull/1/head
Timothy Pearson 12 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,7 +431,7 @@ 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);

@ -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