Forráskód Böngészése

Check tooltip and popup window flags during parameter validation

Sam Lantinga 2 éve
szülő
commit
67e2558310
1 módosított fájl, 7 hozzáadás és 7 törlés
  1. 7 7
      src/video/SDL_video.c

+ 7 - 7
src/video/SDL_video.c

@@ -1946,16 +1946,16 @@ SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y
     /* Parent must be a valid window */
     CHECK_WINDOW_MAGIC(parent, NULL);
 
-    /* Remove invalid flags */
-    flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MOUSE_GRABBED);
-
     /* Popups must specify either the tooltip or popup menu window flags */
-    if ((flags & SDL_WINDOW_TOOLTIP) || (flags & SDL_WINDOW_POPUP_MENU)) {
-        return SDL_CreateWindowInternal(NULL, offset_x, offset_y, w, h, parent, flags);
+    if (!(flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))) {
+        SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag");
+        return NULL;
     }
 
-    SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag");
-    return NULL;
+    /* Remove invalid flags */
+    flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MOUSE_GRABBED);
+
+    return SDL_CreateWindowInternal(NULL, offset_x, offset_y, w, h, parent, flags);
 }
 
 SDL_Window *SDL_CreateWindowFrom(const void *data)