Skip to content

Commit 1d80df8

Browse files
committed
Update surface.c and window.c
1 parent 0ca2d18 commit 1d80df8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src_c/surface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,13 +1610,13 @@ pg_DisplayFormatAlpha(SDL_Surface *surface)
16101610
Uint32 gmask = 0x0000ff00;
16111611
Uint32 bmask = 0x000000ff;
16121612

1613-
if (!pg_GetDefaultConvertFormat()) {
1613+
dformat = pg_GetDefaultConvertFormat();
1614+
if (!dformat) {
16141615
SDL_SetError(
16151616
"No convert format has been set, try display.set_mode()"
16161617
" or Window.get_surface().");
16171618
return NULL;
16181619
}
1619-
dformat = pg_GetDefaultConvertFormat();
16201620

16211621
switch (dformat->BytesPerPixel) {
16221622
case 2:

src_c/window.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ window_get_surface(pgWindowObject *self)
157157
if (!_surf) {
158158
return RAISE(pgExc_SDLError, SDL_GetError());
159159
}
160-
if (self->surf == NULL) {
161-
self->surf = pgSurface_New2(_surf, SDL_FALSE);
162-
if (!self->surf)
163-
return NULL;
164-
}
165-
self->surf->surf = _surf;
166160

167161
if (pg_GetDefaultConvertFormat() == NULL) {
168162
if (pg_SetDefaultConvertFormat(_surf->format->format) == NULL) {
@@ -172,6 +166,13 @@ window_get_surface(pgWindowObject *self)
172166
}
173167
}
174168

169+
if (self->surf == NULL) {
170+
self->surf = pgSurface_New2(_surf, SDL_FALSE);
171+
if (!self->surf)
172+
return NULL;
173+
}
174+
self->surf->surf = _surf;
175+
175176
Py_INCREF(self->surf);
176177
return (PyObject *)self->surf;
177178
}

0 commit comments

Comments
 (0)