Fix #14066: NPE in window_top_toolbar_invalidate()

This commit is contained in:
Michael Steenbeek 2021-02-12 18:48:38 +01:00 committed by GitHub
parent 61536eb1f6
commit 962ef0c02b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -824,11 +824,18 @@ static void window_top_toolbar_invalidate(rct_window* w)
} }
// Zoomed out/in disable. Not sure where this code is in the original. // Zoomed out/in disable. Not sure where this code is in the original.
if (window_get_main()->viewport->zoom == ZoomLevel::min()) const auto* mainWindow = window_get_main();
if (mainWindow == nullptr || mainWindow->viewport == nullptr)
{
log_error("mainWindow or mainWindow->viewport is null!");
return;
}
if (mainWindow->viewport->zoom == ZoomLevel::min())
{ {
w->disabled_widgets |= (1 << WIDX_ZOOM_IN); w->disabled_widgets |= (1 << WIDX_ZOOM_IN);
} }
else if (window_get_main()->viewport->zoom >= ZoomLevel::max()) else if (mainWindow->viewport->zoom >= ZoomLevel::max())
{ {
w->disabled_widgets |= (1 << WIDX_ZOOM_OUT); w->disabled_widgets |= (1 << WIDX_ZOOM_OUT);
} }