diff --git a/settings.cpp b/settings.cpp index 38b0161..439ac7c 100644 --- a/settings.cpp +++ b/settings.cpp @@ -56,7 +56,11 @@ Settings::Settings(QWidget *parent) : } void Settings::selectSettings(QSettings *selectedSettings){ + + this->mySettings = selectedSettings; + sc = new ServerConnection(this, mySettings); + connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleTestConnectionResult(QNetworkReply*))); /* config options layout */ auto cw = this->findChild("centralwidget"); @@ -98,8 +102,6 @@ void Settings::selectSettings(QSettings *selectedSettings){ void Settings::checkConfig(){ saveSetting(); - ServerConnection *sc = new ServerConnection(this, mySettings); - connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleTestConnectionResult(QNetworkReply*))); sc->queryServerVersion(); } @@ -135,7 +137,9 @@ void Settings::handleTestConnectionResult(QNetworkReply* reply){ auto cw = this->findChild("centralwidget"); QGridLayout *layout = static_cast(cw->layout()); - delete currentConfigCheckDisplay; //this removes it from the layout + if(currentConfigCheckDisplay != nullptr){ + delete currentConfigCheckDisplay; //this removes it from the layout + } currentConfigCheckDisplay = testResult; layout->addWidget(testResult, configOptions->length(), 1); } diff --git a/settings.h b/settings.h index af8d733..270dde4 100644 --- a/settings.h +++ b/settings.h @@ -1,6 +1,8 @@ #ifndef SETTINGS_H #define SETTINGS_H +#include "serverconnection.h" + #include #include #include @@ -26,6 +28,7 @@ private slots: void checkConfig(); void handleTestConnectionResult(QNetworkReply *reply); private: + ServerConnection *sc; Ui::settings *ui; QSettings *mySettings; QHash *configLineEditMap;