refactor: Un-singletonize Paths & Updates (#5092)

This commit is contained in:
pajlada
2024-01-16 21:56:43 +01:00
committed by GitHub
parent 7f935665f9
commit 718696db53
60 changed files with 237 additions and 165 deletions
+11 -6
View File
@@ -128,7 +128,12 @@ namespace chatterino {
using namespace std::string_literals;
void CrashHandler::initialize(Settings & /*settings*/, Paths &paths)
CrashHandler::CrashHandler(const Paths &paths_)
: paths(paths_)
{
}
void CrashHandler::initialize(Settings & /*settings*/, const Paths &paths_)
{
auto optSettings = readRecoverySettings(paths);
if (optSettings)
@@ -146,7 +151,7 @@ void CrashHandler::saveShouldRecover(bool value)
{
this->shouldRecover_ = value;
QFile file(QDir(getPaths()->crashdumpDirectory).filePath(RECOVERY_FILE));
QFile file(QDir(this->paths.crashdumpDirectory).filePath(RECOVERY_FILE));
if (!file.open(QFile::WriteOnly | QFile::Truncate))
{
qCWarning(chatterinoCrashhandler)
@@ -160,7 +165,8 @@ void CrashHandler::saveShouldRecover(bool value)
}
#ifdef CHATTERINO_WITH_CRASHPAD
std::unique_ptr<crashpad::CrashpadClient> installCrashHandler(const Args &args)
std::unique_ptr<crashpad::CrashpadClient> installCrashHandler(
const Args &args, const Paths &paths)
{
// Currently, the following directory layout is assumed:
// [applicationDirPath]
@@ -188,15 +194,14 @@ std::unique_ptr<crashpad::CrashpadClient> installCrashHandler(const Args &args)
// Argument passed in --database
// > Crash reports are written to this database, and if uploads are enabled,
// uploaded from this database to a crash report collection server.
auto databaseDir =
base::FilePath(nativeString(getPaths()->crashdumpDirectory));
auto databaseDir = base::FilePath(nativeString(paths.crashdumpDirectory));
auto client = std::make_unique<crashpad::CrashpadClient>();
std::map<std::string, std::string> annotations{
{
"canRestart"s,
canRestart(*getPaths(), args) ? "true"s : "false"s,
canRestart(paths, args) ? "true"s : "false"s,
},
{
"exePath"s,