Browse Source

protect against zero-sized windows

David Rose 14 years ago
parent
commit
38a73900f1

+ 13 - 1
panda/src/display/graphicsOutput.I

@@ -296,7 +296,19 @@ has_size() const {
 ////////////////////////////////////////////////////////////////////
 INLINE bool GraphicsOutput::
 is_valid() const {
-  return _is_valid;
+  return _is_valid && _is_nonzero_size;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::is_nonzero_size
+//       Access: Published
+//  Description: Returns true if the output has a nonzero size in both
+//               X and Y, or false if it is zero (and therefore
+//               invalid).
+////////////////////////////////////////////////////////////////////
+INLINE bool GraphicsOutput::
+is_nonzero_size() const {
+  return _is_nonzero_size;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 0
panda/src/display/graphicsOutput.cxx

@@ -97,6 +97,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe,
     _y_size = win_prop.get_y_size();
   }
   _is_valid = false;
+  _is_nonzero_size = false;
   _flip_ready = false;
   _cube_map_index = -1;
   _cube_map_dr = NULL;
@@ -1207,6 +1208,8 @@ set_size_and_recalc(int x, int y) {
   _y_size = y;
   _has_size = true;
 
+  _is_nonzero_size = (_x_size > 0 && _y_size > 0);
+
   int fb_x_size = get_fb_x_size();
   int fb_y_size = get_fb_y_size();
 

+ 2 - 0
panda/src/display/graphicsOutput.h

@@ -123,6 +123,7 @@ PUBLISHED:
   INLINE int get_sbs_right_y_size() const;
   INLINE bool has_size() const;
   INLINE bool is_valid() const;
+  INLINE bool is_nonzero_size() const;
 
   void set_active(bool active);
   virtual bool is_active() const;
@@ -356,6 +357,7 @@ protected:
   int _y_size;
   bool _has_size;
   bool _is_valid;
+  bool _is_nonzero_size;
 
   static PStatCollector _make_current_pcollector;
   static PStatCollector _copy_texture_pcollector;

+ 0 - 1
panda/src/dxgsg9/wdxGraphicsWindow9.cxx

@@ -1168,7 +1168,6 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) {
 ////////////////////////////////////////////////////////////////////
 bool wdxGraphicsWindow9::
 reset_device_resize_window(UINT new_xsize, UINT new_ysize) {
-  nassertr((new_xsize > 0) && (new_ysize > 0), false);
   bool retval = true;
 
   DXScreenData *screen = NULL;