Skip to content

Commit

Permalink
Use DosBox::Rect methods in assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnovak committed Dec 4, 2023
1 parent 121ba41 commit 0dab866
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/gui/render.cpp
Expand Up @@ -611,8 +611,8 @@ bool RENDER_MaybeAutoSwitchShader([[maybe_unused]] const DosBox::Rect canvas_siz
// uninitialised VideoMode param with width and height set to 0 which
// results in a crash. The proper fix is to make the init sequence 100%
// identical on all platforms, but in the interim this workaround will do.
if (canvas_size_px.w == 0 || canvas_size_px.h == 0 ||
video_mode.width == 0 || video_mode.height == 0) {
if (canvas_size_px.IsEmpty() || video_mode.width == 0 ||
video_mode.height == 0) {
return false;
}

Expand Down
7 changes: 4 additions & 3 deletions src/gui/sdlmain.cpp
Expand Up @@ -734,8 +734,9 @@ static DosBox::Rect get_canvas_size_in_pixels(
SDL_GetWindowSize(sdl.window, &canvas_size_px.w, &canvas_size_px.h);
}
#endif
assert(canvas_size_px.w > 0 && canvas_size_px.h > 0);
return to_rect(canvas_size_px);
const auto r = to_rect(canvas_size_px);
assert(r.HasPositiveSize());
return r;
}

// Logs the source and target resolution including describing scaling method
Expand All @@ -761,7 +762,7 @@ static void log_display_properties(const int render_width_px,
}();

assert(render_width_px > 0 && render_height_px > 0);
assert(draw_size_px.w > 0.0f && draw_size_px.h > 0.0f);
assert(draw_size_px.HasPositiveSize());

const auto scale_x = static_cast<double>(draw_size_px.w) / render_width_px;
const auto scale_y = static_cast<double>(draw_size_px.h) / render_height_px;
Expand Down

0 comments on commit 0dab866

Please sign in to comment.