-void Quassel::handleCrash() {
-#ifdef BUILD_CRASHHANDLER
- void* callstack[128];
- int i, frames = backtrace(callstack, 128);
-
- QFile dumpFile(coreDumpFileName());
- dumpFile.open(QIODevice::Append);
- QTextStream dumpStream(&dumpFile);
-
- dumpStream << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash << '\n';
-
- for (i = 0; i < frames; ++i) {
- Dl_info info;
- dladdr (callstack[i], &info);
- // as a reference:
- // typedef struct
- // {
- // __const char *dli_fname; /* File name of defining object. */
- // void *dli_fbase; /* Load address of that object. */
- // __const char *dli_sname; /* Name of nearest symbol. */
- // void *dli_saddr; /* Exact value of nearest symbol. */
- // } Dl_info;
-
- #if __LP64__
- int addrSize = 16;
- #else
- int addrSize = 8;
- #endif
-
- QString funcName;
- if(info.dli_sname) {
- char *func = abi::__cxa_demangle(info.dli_sname, 0, 0, 0);
- if(func) {
- funcName = QString(func);
- free(func);
- } else {
- funcName = QString(info.dli_sname);
- }
- } else {
- funcName = QString("0x%1").arg((long)info.dli_saddr, addrSize, QLatin1Char('0'));
+
+QStringList Quassel::findDataDirPaths() const
+{
+ // We don't use QStandardPaths for now, as we still need to provide fallbacks for Qt4 and
+ // want to stay consistent.
+
+ QStringList dataDirNames;
+#ifdef Q_OS_WIN
+ dataDirNames << qgetenv("APPDATA") + QCoreApplication::organizationDomain() + "/share/apps/quassel/"
+ << qgetenv("APPDATA") + QCoreApplication::organizationDomain()
+ << QCoreApplication::applicationDirPath();
+#elif defined Q_OS_MAC
+ dataDirNames << QDir::homePath() + "/Library/Application Support/Quassel/"
+ << QCoreApplication::applicationDirPath();
+#else
+ // Linux et al
+
+ // XDG_DATA_HOME is the location for users to override system-installed files, usually in .local/share
+ // This should thus come first.
+ QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME"));
+ if (xdgDataHome.isEmpty())
+ xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
+ dataDirNames << xdgDataHome;
+
+ // Now whatever is configured through XDG_DATA_DIRS
+ QString xdgDataDirs = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
+ if (xdgDataDirs.isEmpty())
+ dataDirNames << "/usr/local/share" << "/usr/share";
+ else
+ dataDirNames << xdgDataDirs.split(':', QString::SkipEmptyParts);
+
+ // Just in case, also check our install prefix
+ dataDirNames << QCoreApplication::applicationDirPath() + "/../share";
+
+ // Normalize and append our application name
+ for (int i = 0; i < dataDirNames.count(); i++)
+ dataDirNames[i] = QDir::cleanPath(dataDirNames.at(i)) + "/quassel/";
+
+#endif
+
+ // Add resource path and workdir just in case.
+ // Workdir should have precedence
+ dataDirNames.prepend(QCoreApplication::applicationDirPath() + "/data/");
+ dataDirNames.append(":/data/");
+
+ // Append trailing '/' and check for existence
+ auto iter = dataDirNames.begin();
+ while (iter != dataDirNames.end()) {
+ if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
+ iter->append(QDir::separator());
+ if (!QFile::exists(*iter))
+ iter = dataDirNames.erase(iter);
+ else
+ ++iter;