File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -183,11 +183,19 @@ window_flip(pgWindowObject *self)
183183{
184184 int result ;
185185
186+ VIDEO_INIT_CHECK ();
187+
186188 Py_BEGIN_ALLOW_THREADS ;
187189 result = SDL_UpdateWindowSurface (self -> _win );
188190 Py_END_ALLOW_THREADS ;
189- if (result )
191+ if (result ) {
192+ if (!self -> surf ) {
193+ return RAISE (pgExc_SDLError ,
194+ "the Window has no surface associated with it, did "
195+ "you forget to call Window.get_surface()" );
196+ }
190197 return RAISE (pgExc_SDLError , SDL_GetError ());
198+ }
191199 Py_RETURN_NONE ;
192200}
193201
Original file line number Diff line number Diff line change @@ -360,6 +360,15 @@ def test_window_flip(self):
360360 self .assertIs (win .flip (), None )
361361 win .destroy ()
362362
363+ # creates a new window with no surface associated
364+ win = Window (size = (640 , 480 ))
365+ self .assertRaisesRegex (
366+ pygame .error ,
367+ "the Window has no surface associated with it, did you forget to call Window.get_surface()" ,
368+ win .flip ,
369+ )
370+ win .destroy ()
371+
363372 def tearDown (self ):
364373 self .win .destroy ()
365374
You can’t perform that action at this time.
0 commit comments