File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -183,11 +183,18 @@ window_flip(pgWindowObject *self)
183183{
184184 int result ;
185185
186+ if (!self -> surf ) {
187+ return RAISE (pgExc_SDLError ,
188+ "the Window has no surface associated with it, did "
189+ "you forget to call Window.get_surface()" );
190+ }
191+
186192 Py_BEGIN_ALLOW_THREADS ;
187193 result = SDL_UpdateWindowSurface (self -> _win );
188194 Py_END_ALLOW_THREADS ;
189- if (result )
195+ if (result ) {
190196 return RAISE (pgExc_SDLError , SDL_GetError ());
197+ }
191198 Py_RETURN_NONE ;
192199}
193200
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