Skip to content

Commit

Permalink
Fix OpenTTD#10993: Crash log when font caches not initialised
Browse files Browse the repository at this point in the history
See also: OpenTTD#10836
  • Loading branch information
JGRennison committed Jun 16, 2023
1 parent ee8b03e commit e8ff5a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/crashlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,25 @@ void CrashLog::LogConfiguration(std::back_insert_iterator<std::string> &output_i
VideoDriver::GetInstance() == nullptr ? "none" : VideoDriver::GetInstance()->GetInfoString()
);

auto log_font = [&](FontSize fs) -> std::string {
FontCache *fc = FontCache::Get(fs);
if (fc != nullptr) {
return fc->GetFontName();
} else {
return "[NULL]";
}
};

fmt::format_to(output_iterator,
"Fonts:\n"
" Small: {}\n"
" Medium: {}\n"
" Large: {}\n"
" Mono: {}\n\n",
FontCache::Get(FS_SMALL)->GetFontName(),
FontCache::Get(FS_NORMAL)->GetFontName(),
FontCache::Get(FS_LARGE)->GetFontName(),
FontCache::Get(FS_MONO)->GetFontName()
log_font(FS_SMALL),
log_font(FS_NORMAL),
log_font(FS_LARGE),
log_font(FS_MONO)
);

fmt::format_to(output_iterator, "AI Configuration (local: {}) (current: {}):\n", _local_company, _current_company);
Expand Down

0 comments on commit e8ff5a7

Please sign in to comment.