mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +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 <ostream>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -90,6 +92,7 @@ void Window::create(VideoMode mode, const String& title, std::uint32_t style, co
|
|||||||
if (!mode.isValid())
|
if (!mode.isValid())
|
||||||
{
|
{
|
||||||
err() << "The requested video mode is not available, switching to a valid mode" << std::endl;
|
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];
|
mode = VideoMode::getFullscreenModes()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user