mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Remove getPaths() usage from CrashHandler
This commit is contained in:
parent
6ad5c63fca
commit
3f599ea609
4 changed files with 20 additions and 9 deletions
|
@ -120,7 +120,7 @@ Application::Application(Settings &_settings, const Paths &paths,
|
||||||
, toasts(&this->emplace<Toasts>())
|
, toasts(&this->emplace<Toasts>())
|
||||||
, imageUploader(&this->emplace<ImageUploader>())
|
, imageUploader(&this->emplace<ImageUploader>())
|
||||||
, seventvAPI(&this->emplace<SeventvAPI>())
|
, seventvAPI(&this->emplace<SeventvAPI>())
|
||||||
, crashHandler(&this->emplace<CrashHandler>())
|
, crashHandler(&this->emplace<CrashHandler>(new CrashHandler(paths)))
|
||||||
|
|
||||||
, commands(&this->emplace<CommandController>())
|
, commands(&this->emplace<CommandController>())
|
||||||
, notifications(&this->emplace<NotificationController>())
|
, notifications(&this->emplace<NotificationController>())
|
||||||
|
|
|
@ -65,7 +65,7 @@ int main(int argc, char **argv)
|
||||||
const Args args(a, *paths);
|
const Args args(a, *paths);
|
||||||
|
|
||||||
#ifdef CHATTERINO_WITH_CRASHPAD
|
#ifdef CHATTERINO_WITH_CRASHPAD
|
||||||
const auto crashpadHandler = installCrashHandler(args);
|
const auto crashpadHandler = installCrashHandler(args, *paths);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// run in gui mode or browser extension host mode
|
// run in gui mode or browser extension host mode
|
||||||
|
|
|
@ -128,7 +128,12 @@ namespace chatterino {
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
||||||
void CrashHandler::initialize(Settings & /*settings*/, const Paths &paths)
|
CrashHandler::CrashHandler(const Paths &paths_)
|
||||||
|
: paths(paths_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CrashHandler::initialize(Settings & /*settings*/, const Paths &paths_)
|
||||||
{
|
{
|
||||||
auto optSettings = readRecoverySettings(paths);
|
auto optSettings = readRecoverySettings(paths);
|
||||||
if (optSettings)
|
if (optSettings)
|
||||||
|
@ -146,7 +151,7 @@ void CrashHandler::saveShouldRecover(bool value)
|
||||||
{
|
{
|
||||||
this->shouldRecover_ = 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))
|
if (!file.open(QFile::WriteOnly | QFile::Truncate))
|
||||||
{
|
{
|
||||||
qCWarning(chatterinoCrashhandler)
|
qCWarning(chatterinoCrashhandler)
|
||||||
|
@ -160,7 +165,8 @@ void CrashHandler::saveShouldRecover(bool value)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHATTERINO_WITH_CRASHPAD
|
#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:
|
// Currently, the following directory layout is assumed:
|
||||||
// [applicationDirPath]
|
// [applicationDirPath]
|
||||||
|
@ -188,15 +194,14 @@ std::unique_ptr<crashpad::CrashpadClient> installCrashHandler(const Args &args)
|
||||||
// Argument passed in --database
|
// Argument passed in --database
|
||||||
// > Crash reports are written to this database, and if uploads are enabled,
|
// > Crash reports are written to this database, and if uploads are enabled,
|
||||||
// uploaded from this database to a crash report collection server.
|
// uploaded from this database to a crash report collection server.
|
||||||
auto databaseDir =
|
auto databaseDir = base::FilePath(nativeString(paths.crashdumpDirectory));
|
||||||
base::FilePath(nativeString(getPaths()->crashdumpDirectory));
|
|
||||||
|
|
||||||
auto client = std::make_unique<crashpad::CrashpadClient>();
|
auto client = std::make_unique<crashpad::CrashpadClient>();
|
||||||
|
|
||||||
std::map<std::string, std::string> annotations{
|
std::map<std::string, std::string> annotations{
|
||||||
{
|
{
|
||||||
"canRestart"s,
|
"canRestart"s,
|
||||||
canRestart(*getPaths(), args) ? "true"s : "false"s,
|
canRestart(paths, args) ? "true"s : "false"s,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"exePath"s,
|
"exePath"s,
|
||||||
|
|
|
@ -13,10 +13,15 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Args;
|
class Args;
|
||||||
|
class Paths;
|
||||||
|
|
||||||
class CrashHandler : public Singleton
|
class CrashHandler : public Singleton
|
||||||
{
|
{
|
||||||
|
const Paths &paths;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit CrashHandler(const Paths &paths_);
|
||||||
|
|
||||||
bool shouldRecover() const
|
bool shouldRecover() const
|
||||||
{
|
{
|
||||||
return this->shouldRecover_;
|
return this->shouldRecover_;
|
||||||
|
@ -32,7 +37,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CHATTERINO_WITH_CRASHPAD
|
#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);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue