Fix crash when starting to add connection.

Caused by uninitialized variable. Commit contains some minor style fixes also.
This commit is contained in:
eelke 2019-09-02 16:33:13 +02:00
parent 7f88b98cdd
commit bcfd82c27d
5 changed files with 32 additions and 27 deletions

View file

@ -14,38 +14,43 @@
#include <QSpinBox>
#include <QComboBox>
#include <QDialog>
#include <QDebug>
#define SET_OBJECT_NAME(var) var->setObjectName(#var)
void ConnectionConfigurationWidget::editExistingInWindow(ConnectionController *ctrl, const ConnectionConfig &cfg)
{
auto w = new ConnectionConfigurationWidget(ctrl->getConnectionTreeModel());
w->setData(cfg);
try {
auto w = new ConnectionConfigurationWidget(ctrl->getConnectionTreeModel());
w->setData(cfg);
auto btn_hbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
//auto btn_test = btn_hbox->addButton(tr("Test"), QDialogButtonBox::ActionRole);
auto btn_hbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
//auto btn_test = btn_hbox->addButton(tr("Test"), QDialogButtonBox::ActionRole);
auto vbox = new QVBoxLayout;
vbox->addWidget(w);
vbox->addWidget(btn_hbox);
auto vbox = new QVBoxLayout;
vbox->addWidget(w);
vbox->addWidget(btn_hbox);
auto win = new QDialog;
win->setWindowTitle(tr("Edit connection configuration"));
win->setLayout(vbox);
win->setAttribute( Qt::WA_DeleteOnClose, true );
auto win = new QDialog;
win->setWindowTitle(tr("Edit connection configuration"));
win->setLayout(vbox);
win->setAttribute( Qt::WA_DeleteOnClose, true );
win->connect(btn_hbox, &QDialogButtonBox::accepted, [ctrl, w, win] () {
auto [grp, cc] = w->data();
ctrl->getConnectionTreeModel()->save(grp, cc);
win->accept();
});
win->connect(btn_hbox, &QDialogButtonBox::rejected, [win] ()
{
win->reject();
QObject::connect(btn_hbox, &QDialogButtonBox::accepted, [ctrl, w, win] () {
auto [grp, cc] = w->data();
ctrl->getConnectionTreeModel()->save(grp, cc);
win->accept();
});
QObject::connect(btn_hbox, &QDialogButtonBox::rejected, [win] ()
{
win->reject();
});
win->show();
win->show();
}
catch (const std::exception &ex) {
qDebug() << "exception: " << QString::fromUtf8(ex.what());
}
}
ConnectionConfigurationWidget::ConnectionConfigurationWidget(ConnectionTreeModel *connection_model, QWidget *parent)