- use a local file with QSettings at all times. Registry is such a pain..

Mon, 23 Dec 2013 11:57:32 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 23 Dec 2013 11:57:32 +0200
changeset 589
1417828920e6
parent 588
720f7480c6b7
child 590
7aec744ce97b

- use a local file with QSettings at all times. Registry is such a pain..

changelog.txt file | annotate | diff | comparison | revisions
src/config.cc file | annotate | diff | comparison | revisions
--- 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:
--- 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<T*> (cfg));
+		{	if (cfg->getType() == type)
+				return *reinterpret_cast<T*> (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();
 }
 

mercurial