diff --git a/src/Preferences.cc b/src/Preferences.cc index 771a6f8c..73cbcfb8 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -144,6 +144,7 @@ void Preferences::init() { Preferences::~Preferences() { removeDefaultSettings(); + instance = NULL; } /** @@ -501,15 +502,19 @@ void Preferences::apply() const emit syntaxHighlightChanged(getValue("editor/syntaxhighlight").toString()); } -void Preferences::create(QWidget *parent, QStringList colorSchemes) +void Preferences::create(QStringList colorSchemes) { + if (instance != NULL) { + return; + } + std::list names = ColorMap::inst()->colorSchemeNames(true); QStringList renderColorSchemes; foreach (std::string name, names) { renderColorSchemes << name.c_str(); } - instance = new Preferences(parent); + instance = new Preferences(); instance->syntaxHighlight->clear(); instance->syntaxHighlight->addItems(colorSchemes); instance->colorSchemeChooser->clear(); diff --git a/src/Preferences.h b/src/Preferences.h index a40e92cd..0f862eb2 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -11,7 +11,7 @@ class Preferences : public QMainWindow, public Ui::Preferences public: ~Preferences(); - static void create(QWidget *parent, QStringList colorSchemes); + static void create(QStringList colorSchemes); static Preferences *inst(); QVariant getValue(const QString &key) const; diff --git a/src/mainwin.cc b/src/mainwin.cc index be3c4337..776a46ed 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -201,7 +201,7 @@ MainWindow::MainWindow(const QString &filename) #endif editor = new LegacyEditor(editorDockContents); - Preferences::create(this, editor->colorSchemes()); + Preferences::create(editor->colorSchemes()); editorDockContents->layout()->addWidget(editor); diff --git a/src/openscad.cc b/src/openscad.cc index 80c1b049..bbd6c265 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -625,13 +625,14 @@ int gui(vector &inputFiles, const fs::path &original_path, int argc, cha } MainWindow *mainwin; -#ifdef ENABLE_MDI - BOOST_FOREACH(const string &infile, inputFiles) { - mainwin = new MainWindow(assemblePath(original_path, infile)); + bool isMdi = settings.value("advanced/mdi", true).toBool(); + if (isMdi) { + BOOST_FOREACH(const string &infile, inputFiles) { + mainwin = new MainWindow(assemblePath(original_path, infile)); + } + } else { + mainwin = new MainWindow(assemblePath(original_path, inputFiles[0])); } -#else - mainwin = new MainWindow(assemblePath(original_path, inputFiles[0])); -#endif app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); int rc = app.exec(); @@ -782,11 +783,6 @@ int main(int argc, char **argv) if (vm.count("input-file")) { inputFiles = vm["input-file"].as >(); } -#ifndef ENABLE_MDI - if (inputFiles.size() > 1) { - help(argv[0]); - } -#endif if (vm.count("colorscheme")) { arg_colorscheme = vm["colorscheme"].as(); @@ -807,6 +803,9 @@ int main(int argc, char **argv) } if (arg_info || cmdlinemode) { + if (inputFiles.size() > 1) { + help(argv[0]); + } rc = cmdline(deps_output_file, inputFiles[0], camera, output_file, original_path, renderer, argc, argv); } else if (QtUseGUI()) {