mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
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:
parent
a0c10b8dfb
commit
a8e901e754
@ -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];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user