2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Minimize amount of code to rebuild when switching options

This commit is contained in:
Ilya Fedin
2023-09-22 04:24:11 +04:00
committed by John Preston
parent 3db0b11a6b
commit 1bde096417
16 changed files with 82 additions and 51 deletions

View File

@@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <new>
#include <mutex>
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
#ifdef Q_OS_WIN
#include <new.h>
@@ -48,7 +48,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#endif // Q_OS_MAC
#endif // Q_OS_WIN
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
namespace CrashReports {
namespace {
@@ -59,7 +59,7 @@ using AnnotationRefs = std::map<std::string, const QString*>;
Annotations ProcessAnnotations;
AnnotationRefs ProcessAnnotationRefs;
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
QString ReportPath;
FILE *ReportFile = nullptr;
@@ -290,7 +290,7 @@ bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context,
}
#endif // !Q_OS_MAC || MAC_USE_BREAKPAD
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
} // namespace
@@ -314,7 +314,7 @@ QString PlatformString() {
}
void StartCatching() {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(ApiId).toUtf8().constData();
ProcessAnnotations["Version"] = (cAlphaVersion()
@@ -380,21 +380,21 @@ void StartCatching() {
-1
);
#endif // else for Q_OS_WIN || Q_OS_MAC
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
}
void FinishCatching() {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
#if !defined Q_OS_MAC || defined MAC_USE_BREAKPAD
delete base::take(BreakpadExceptionHandler);
#endif // !Q_OS_MAC || MAC_USE_BREAKPAD
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
}
StartResult Start() {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
ReportPath = cWorkingDir() + u"tdata/working"_q;
#ifdef Q_OS_WIN
@@ -420,12 +420,12 @@ StartResult Start() {
return lastdump;
}
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
return Restart();
}
Status Restart() {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
if (ReportFile) {
return Started;
}
@@ -470,13 +470,13 @@ Status Restart() {
LOG(("FATAL: Could not open '%1' for writing!").arg(ReportPath));
return CantOpen;
#else // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#else // !TDESKTOP_DISABLE_CRASH_REPORTS
return Started;
#endif // else for !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // else for !TDESKTOP_DISABLE_CRASH_REPORTS
}
void Finish() {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
FinishCatching();
if (ReportFile) {
@@ -489,7 +489,7 @@ void Finish() {
unlink(ReportPath.toUtf8().constData());
#endif // else for Q_OS_WIN
}
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
}
void SetAnnotation(const std::string &key, const QString &value) {
@@ -539,7 +539,7 @@ void SetAnnotationRef(const std::string &key, const QString *valuePtr) {
}
}
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
dump::~dump() {
if (ReportFile) {
@@ -604,6 +604,6 @@ const dump &operator<<(const dump &stream, double num) {
return stream;
}
#endif // DESKTOP_APP_DISABLE_CRASH_REPORTS
#endif // TDESKTOP_DISABLE_CRASH_REPORTS
} // namespace CrashReports