[kstars] kstars/auxiliary: Only add "kstars" directory if using QStandardPaths::GenericDataLocation

Akarsh Simha akarsh at kde.org
Wed Aug 17 20:39:45 UTC 2016


Git commit ff5332eb8263a57867b16931982dae53f077a940 by Akarsh Simha.
Committed on 17/08/2016 at 20:41.
Pushed by asimha into branch 'master'.

Only add "kstars" directory if using QStandardPaths::GenericDataLocation

In my current opinion,

ideally, we should not be doing this. We should instead use
QStandardPaths::AppDataLocation within our code, and reserve
GenericDataLocation only when we actually need to store something that
is shared across applications. That permits us to actually use
QStandardPaths::GenericDataLocation when we actually need it.

This patch fixes misbehavior with respect to image handling in the
Observation Planner.

CCMAIL: afedoskin3 at gmail.com, kstars-devel at kde.org

M  +8    -4    kstars/auxiliary/kspaths.cpp

http://commits.kde.org/kstars/ff5332eb8263a57867b16931982dae53f077a940

diff --git a/kstars/auxiliary/kspaths.cpp b/kstars/auxiliary/kspaths.cpp
index eaac7c4..62880f5 100644
--- a/kstars/auxiliary/kspaths.cpp
+++ b/kstars/auxiliary/kspaths.cpp
@@ -14,8 +14,10 @@ QString KSPaths::locate(QStandardPaths::StandardLocation location, const QString
     }
     return file;
 #else
-    return QStandardPaths::locate(location, "kstars" + QDir::separator() +
-                                  fileName,options);
+    QString file = fileName;
+    if( location == QStandardPaths::GenericDataLocation || location == QStandardPaths::GenericConfigLocation )
+        file = "kstars" + QDir::separator() + fileName;
+    return QStandardPaths::locate(location, file, options);
 #endif
 }
 
@@ -31,7 +33,9 @@ QStringList KSPaths::locateAll(QStandardPaths::StandardLocation location, const
     }
     return file;
 #else
-    return QStandardPaths::locateAll(location, "kstars" + QDir::separator() +
-                                     fileName,options);
+    QString file = fileName;
+    if( location == QStandardPaths::GenericDataLocation || location == QStandardPaths::GenericConfigLocation )
+        file = "kstars" + QDir::separator() + fileName;
+    return QStandardPaths::locateAll(location, file, options);
 #endif
 }



More information about the Kstars-devel mailing list