mirror of https://github.com/OpenTTD/OpenTTD
Change: mention in MacOS / Windows crashlog popup when files couldn't be generated (#11239)
For example, if the crash.sav couldn't be created, and the TryExcept detected an issue, write out that the file is not available in the popup.pull/11240/head
parent
be9a690f41
commit
de5e338a76
|
@ -425,18 +425,16 @@ void CrashLog::SendSurvey() const
|
||||||
* Makes the crash log, writes it to a file and then subsequently tries
|
* Makes the crash log, writes it to a file and then subsequently tries
|
||||||
* to make a crash dump and crash savegame. It uses DEBUG to write
|
* to make a crash dump and crash savegame. It uses DEBUG to write
|
||||||
* information like paths to the console.
|
* information like paths to the console.
|
||||||
* @return true when everything is made successfully.
|
|
||||||
*/
|
*/
|
||||||
bool CrashLog::MakeCrashLog()
|
void CrashLog::MakeCrashLog()
|
||||||
{
|
{
|
||||||
/* Don't keep looping logging crashes. */
|
/* Don't keep looping logging crashes. */
|
||||||
static bool crashlogged = false;
|
static bool crashlogged = false;
|
||||||
if (crashlogged) return false;
|
if (crashlogged) return;
|
||||||
crashlogged = true;
|
crashlogged = true;
|
||||||
|
|
||||||
crashlog.reserve(65536);
|
crashlog.reserve(65536);
|
||||||
auto output_iterator = std::back_inserter(crashlog);
|
auto output_iterator = std::back_inserter(crashlog);
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
fmt::print("Crash encountered, generating crash log...\n");
|
fmt::print("Crash encountered, generating crash log...\n");
|
||||||
this->FillCrashLog(output_iterator);
|
this->FillCrashLog(output_iterator);
|
||||||
|
@ -444,43 +442,42 @@ bool CrashLog::MakeCrashLog()
|
||||||
fmt::print("Crash log generated.\n\n");
|
fmt::print("Crash log generated.\n\n");
|
||||||
|
|
||||||
fmt::print("Writing crash log to disk...\n");
|
fmt::print("Writing crash log to disk...\n");
|
||||||
bool bret = this->TryExecute("crashlog", [this]() { return this->WriteCrashLog(); });
|
bool ret = this->TryExecute("crashlog", [this]() { return this->WriteCrashLog(); });
|
||||||
if (bret) {
|
if (ret) {
|
||||||
fmt::print("Crash log written to {}. Please add this file to any bug reports.\n\n", this->crashlog_filename);
|
fmt::print("Crash log written to {}. Please add this file to any bug reports.\n\n", this->crashlog_filename);
|
||||||
} else {
|
} else {
|
||||||
fmt::print("Writing crash log failed. Please attach the output above to any bug reports.\n\n");
|
fmt::print("Writing crash log failed. Please attach the output above to any bug reports.\n\n");
|
||||||
ret = false;
|
this->crashlog_filename = "(failed to write crash log)";
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::print("Writing crash dump to disk...\n");
|
fmt::print("Writing crash dump to disk...\n");
|
||||||
bret = this->TryExecute("crashdump", [this]() { return this->WriteCrashDump(); });
|
ret = this->TryExecute("crashdump", [this]() { return this->WriteCrashDump(); });
|
||||||
if (bret) {
|
if (ret) {
|
||||||
fmt::print("Crash dump written to {}. Please add this file to any bug reports.\n\n", this->crashdump_filename);
|
fmt::print("Crash dump written to {}. Please add this file to any bug reports.\n\n", this->crashdump_filename);
|
||||||
} else {
|
} else {
|
||||||
fmt::print("Writing crash dump failed.\n\n");
|
fmt::print("Writing crash dump failed.\n\n");
|
||||||
|
this->crashdump_filename = "(failed to write crash dump)";
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::print("Writing crash savegame...\n");
|
fmt::print("Writing crash savegame...\n");
|
||||||
bret = this->TryExecute("savegame", [this]() { return this->WriteSavegame(); });
|
ret = this->TryExecute("savegame", [this]() { return this->WriteSavegame(); });
|
||||||
if (bret) {
|
if (ret) {
|
||||||
fmt::print("Crash savegame written to {}. Please add this file and the last (auto)save to any bug reports.\n\n", this->savegame_filename);
|
fmt::print("Crash savegame written to {}. Please add this file and the last (auto)save to any bug reports.\n\n", this->savegame_filename);
|
||||||
} else {
|
} else {
|
||||||
ret = false;
|
|
||||||
fmt::print("Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
|
fmt::print("Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n");
|
||||||
|
this->savegame_filename = "(failed to write crash savegame)";
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::print("Writing crash screenshot...\n");
|
fmt::print("Writing crash screenshot...\n");
|
||||||
bret = this->TryExecute("screenshot", [this]() { return this->WriteScreenshot(); });
|
ret = this->TryExecute("screenshot", [this]() { return this->WriteScreenshot(); });
|
||||||
if (bret) {
|
if (ret) {
|
||||||
fmt::print("Crash screenshot written to {}. Please add this file to any bug reports.\n\n", this->screenshot_filename);
|
fmt::print("Crash screenshot written to {}. Please add this file to any bug reports.\n\n", this->screenshot_filename);
|
||||||
} else {
|
} else {
|
||||||
ret = false;
|
|
||||||
fmt::print("Writing crash screenshot failed.\n\n");
|
fmt::print("Writing crash screenshot failed.\n\n");
|
||||||
|
this->screenshot_filename = "(failed to write crash screenshot)";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->TryExecute("survey", [this]() { this->SendSurvey(); return true; });
|
this->TryExecute("survey", [this]() { this->SendSurvey(); return true; });
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
|
|
||||||
void SendSurvey() const;
|
void SendSurvey() const;
|
||||||
|
|
||||||
bool MakeCrashLog();
|
void MakeCrashLog();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialiser for crash logs; do the appropriate things so crashes are
|
* Initialiser for crash logs; do the appropriate things so crashes are
|
||||||
|
|
Loading…
Reference in New Issue