Don't assert when malformed regions are detected.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 21 Jul 2009 11:01:10 +0000 (07:01 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 21 Jul 2009 11:01:10 +0000 (07:01 -0400)
Instead print a message to stderr so that it will end up in the X log
file.

pixman/pixman-region.c

index 7820b94..387dbba 100644 (file)
 #define PIXREGION_END(reg) PIXREGION_BOX (reg, (reg)->data->numRects - 1)
 
 #define GOOD_RECT(rect) ((rect)->x1 < (rect)->x2 && (rect)->y1 < (rect)->y2)
-#define GOOD(reg) assert (PREFIX (_selfcheck) (reg))
+
+#define PIXMAN_REGION_LOG_FAILURES
+
+#if defined PIXMAN_REGION_DEBUG
+
+#    define GOOD(reg) assert (PREFIX (_selfcheck) (reg))
+
+#elif defined PIXMAN_REGION_LOG_FAILURES
+
+static void
+log_region_error (void)
+{
+    static int n_messages = 0;
+
+    if (n_messages < 50)
+    {
+       fprintf (stderr,
+                "*** BUG ***\n"
+                "Malformed region detected\n"
+                "Set a breakpoint on 'log_region_error' to debug\n\n");
+
+       n_messages++;
+    }
+}
+
+#define GOOD(reg)                                                      \
+    do                                                                 \
+    {                                                                  \
+       if (!PREFIX (_selfcheck (reg)))                                 \
+           log_region_error ();                                        \
+    } while (0)
+
+#else
+
+#define GOOD(reg)
+
+#endif
 
 static const box_type_t PREFIX (_empty_box_) = { 0, 0, 0, 0 };
 static const region_data_type_t PREFIX (_empty_data_) = { 0, 0 };
@@ -467,7 +503,7 @@ PREFIX (_copy) (region_type_t *dst, region_type_t *src)
 {
     GOOD (dst);
     GOOD (src);
-    
+
     if (dst == src)
        return TRUE;