refactor: Un-singletonize Paths & Updates (#5092)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user