# HG changeset patch # User Santeri Piippo # Date 1387792652 -7200 # Node ID 1417828920e6e5a907b0449f49dd19892caf77dd # Parent 720f7480c6b77d32f231607c68e47623b26eb013 - use a local file with QSettings at all times. Registry is such a pain.. diff -r 720f7480c6b7 -r 1417828920e6 changelog.txt --- a/changelog.txt Mon Dec 23 11:48:55 2013 +0200 +++ b/changelog.txt Mon Dec 23 11:57:32 2013 +0200 @@ -6,9 +6,6 @@ - Added close, close all and save all actions. - Added ability to download parts from the Parts Tracker or from a custom-specified URL. If the resulting file contains references to unknown files, LDForge attempts to recursively download all of them. -- Converted the configuration code to use QSettings, in practice this means the configuration file moved to - the registry under Windows and into ~/.config/LDForge under Linux. Unfortunately this means settings get - lost during transition from version 0.2 and 0.3. - Added a new editing mode for drawing circles. - Fixed: File loading would skip every 300th line (don't ask me how this managed to happen). - Major corrections to the primitive generator: diff -r 720f7480c6b7 -r 1417828920e6 src/config.cc --- a/src/config.cc Mon Dec 23 11:48:55 2013 +0200 +++ b/src/config.cc Mon Dec 23 11:57:32 2013 +0200 @@ -42,16 +42,10 @@ static int g_cfgPointerCursor = 0; // ============================================================================= -// Get the QSettings object. A portable build refers to a file in the current -// directory, a non-portable build to ~/.config/LDForge or to registry. +// Get the QSettings object. // ----------------------------------------------------------------------------- static QSettings* getSettingsObject() -{ -#ifdef PORTABLE - return new QSettings (str (APPNAME).toLower() + EXTENSION, QSettings::IniFormat); -#else - return new QSettings; -#endif // PORTABLE +{ return new QSettings (UNIXNAME EXTENSION, QSettings::IniFormat); } Config::Config (const char* name, const char* defstring) : @@ -111,15 +105,14 @@ } // ============================================================================= -// Where is the configuration file located at? Note that the Windows build uses -// the registry so only use this with PORTABLE code. +// Where is the configuration file located at? // ----------------------------------------------------------------------------- str Config::filepath (str file) { return Config::dirpath() + DIRSLASH + file; } // ============================================================================= -// Directory of the configuration file. PORTABLE code here as well. +// Directory of the configuration file. // ----------------------------------------------------------------------------- str Config::dirpath() { QSettings* cfg = getSettingsObject(); @@ -147,12 +140,16 @@ break; if (cfg->name == name) - { assert (cfg->getType() == type); - return *(reinterpret_cast (cfg)); + { if (cfg->getType() == type) + return *reinterpret_cast (cfg); + else + { fprint (stderr, "type of %1 is %2, not %3\n", name, cfg->getType(), type); + abort(); + } } } - qFatal ("couldn't find a configuration element with name %s", name.toLocal8Bit().constData()); + fprint (stderr, "couldn't find a configuration element with name %1", name); abort(); }