diff -r b5df72b194f4 -r 8d4b8a9df724 src/ldpaths.cpp --- a/src/ldpaths.cpp Thu Mar 09 00:40:07 2017 +0200 +++ b/src/ldpaths.cpp Thu Mar 09 00:54:45 2017 +0200 @@ -21,25 +21,33 @@ #include "mainwindow.h" #include "dialogs/ldrawpathdialog.h" -LDPaths::LDPaths (Configuration *config, QObject* parent) : - QObject(parent), - m_config(config), - m_dialog(nullptr) {} +LDPaths::LDPaths(QObject* parent) : + QObject {parent}, + m_dialog {nullptr} {} +LDPaths::~LDPaths() +{ + delete m_dialog; +} -void LDPaths::checkPaths() +bool LDPaths::checkPaths() { - QString pathconfig = m_config->lDrawPath(); + QString pathconfig = configuration().lDrawPath(); - if (not configurePaths (pathconfig)) + if (configurePaths (pathconfig)) + { + return true; + } + else { m_dialog = new LDrawPathDialog (pathconfig, false); connect(m_dialog, &LDrawPathDialog::pathChanged, this, &LDPaths::configurePaths); if (m_dialog->exec() != QDialog::Accepted) - exit(1); - else - m_config->setLDrawPath(m_dialog->path()); + return false; + + configuration().setLDrawPath(m_dialog->path()); + return true; } } @@ -70,19 +78,19 @@ bool LDPaths::configurePaths (QString path) { - QDir dir (path); - bool ok = isValid (dir); + QDir dir {path}; + bool ok = isValid(dir); if (ok) { baseDir() = dir; - ldConfigPath() = format ("%1" DIRSLASH "LDConfig.ldr", path); - partsDir() = QDir (path + DIRSLASH "parts"); - primitivesDir() = QDir (path + DIRSLASH "p"); + ldConfigPath() = format("%1/LDConfig.ldr", path); + partsDir() = path + "/parts"; + primitivesDir() = path + "/p"; } if (m_dialog) - m_dialog->setStatusText (m_error.isEmpty() ? "OK" : m_error, ok); + m_dialog->setStatusText(m_error.isEmpty() ? "OK" : m_error, ok); return ok; }