- 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'));
+ dumpStream << "Fatal: " << msg << '\n';
+ dumpStream.flush();
+ dumpFile.close();
+#endif
+}
+
+const QString &Quassel::coreDumpFileName() {
+ if(_coreDumpFileName.isEmpty()) {
+ _coreDumpFileName = QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm"));
+ QFile dumpFile(_coreDumpFileName);
+ dumpFile.open(QIODevice::Append);
+ QTextStream dumpStream(&dumpFile);
+ dumpStream << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash << '\n';
+ qDebug() << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash;
+ dumpStream.flush();
+ dumpFile.close();
+ }
+ return _coreDumpFileName;
+}
+
+QString Quassel::configDirPath() {
+ if(!_configDirPath.isEmpty())
+ return _configDirPath;
+
+ if(Quassel::isOptionSet("datadir")) {
+ qWarning() << "Obsolete option --datadir used!";
+ _configDirPath = Quassel::optionValue("datadir");
+ } else if(Quassel::isOptionSet("configdir")) {
+ _configDirPath = Quassel::optionValue("configdir");
+ } else {
+
+#ifdef Q_WS_MAC
+ // On Mac, the path is always the same
+ _configDirPath = QDir::homePath() + "/Library/Application Support/Quassel/";
+#else
+ // We abuse QSettings to find us a sensible path on the other platforms
+# ifdef Q_WS_WIN
+ // don't use the registry
+ QSettings::Format format = QSettings::IniFormat;
+# else
+ QSettings::Format format = QSettings::NativeFormat;
+# endif
+ QSettings s(format, QSettings::UserScope, QCoreApplication::organizationDomain(), buildInfo().applicationName);
+ QFileInfo fileInfo(s.fileName());
+ _configDirPath = fileInfo.dir().absolutePath();
+#endif /* Q_WS_MAC */
+ }
+
+ if(!_configDirPath.endsWith(QDir::separator()) && !_configDirPath.endsWith('/'))
+ _configDirPath += QDir::separator();
+
+ QDir qDir(_configDirPath);
+ if(!qDir.exists(_configDirPath)) {
+ if(!qDir.mkpath(_configDirPath)) {
+ qCritical() << "Unable to create Quassel config directory:" << qPrintable(qDir.absolutePath());
+ return QString();