Assert that a video mode exists before trying to use it

This converts a segfault into a more predictable failure, at least
in debug builds.
This commit is contained in:
Chris Thrasher 2023-06-16 16:09:34 -06:00
parent a0c10b8dfb
commit a8e901e754

View File

@ -34,6 +34,8 @@
#include <ostream>
#include <cassert>
namespace sf
{
@ -90,6 +92,7 @@ void Window::create(VideoMode mode, const String& title, std::uint32_t style, co
if (!mode.isValid())
{
err() << "The requested video mode is not available, switching to a valid mode" << std::endl;
assert(!VideoMode::getFullscreenModes().empty() && "No video modes available");
mode = VideoMode::getFullscreenModes()[0];
}