Commit 3526b08e authored by Matthias Clasen's avatar Matthias Clasen

Clean up debug features

Introduce a GTK_DEBUG_CHECK() macro and use it to check for
GTK_DEBUG flags everywhere. Also guard all such places by
parent 1b155887
......@@ -752,7 +752,7 @@ _gtk_builder_construct (GtkBuilder *builder,
g_object_set_property (obj, param->name, &param->value);
#if G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
if (GTK_DEBUG_CHECK (BUILDER))
{
gchar *str = g_strdup_value_contents ((const GValue*)&param->value);
g_print ("set %s: %s = %s\n", info->id, param->name, str);
......@@ -816,7 +816,7 @@ _gtk_builder_apply_properties (GtkBuilder *builder,
g_object_set_property (info->object, param->name, &param->value);
#if G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
if (GTK_DEBUG_CHECK (BUILDER))
{
gchar *str = g_strdup_value_contents ((const GValue*)&param->value);
g_print ("set %s: %s = %s\n", info->id, param->name, str);
......
......@@ -926,7 +926,7 @@ start_element (GMarkupParseContext *context,
ParserData *data = (ParserData*)user_data;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_BUILDER)
if (GTK_DEBUG_CHECK (BUILDER))
{
GString *tags = g_string_new ("");
int i;
......
......@@ -1265,8 +1265,10 @@ gtk_css_node_validate_internal (GtkCssNode *cssnode,
* Note that this also completely revalidates child widgets all
* the time.
*/
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_NO_CSS_CACHE))
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (NO_CSS_CACHE))
cssnode->pending_changes |= GTK_CSS_CHANGE_ANY;
#endif
if (!cssnode->invalid)
return;
......
......@@ -59,12 +59,15 @@ typedef enum {
#ifdef G_ENABLE_DEBUG
#define GTK_DEBUG_CHECK(type) G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_##type)
#define GTK_NOTE(type,action) G_STMT_START { \
if (gtk_get_debug_flags () & GTK_DEBUG_##type) \
if (GTK_DEBUG_CHECK (type)) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GTK_DEBUG_CHECK(type) 0
#define GTK_NOTE(type, action)
#endif /* G_ENABLE_DEBUG */
......
......@@ -122,8 +122,7 @@ _gtk_icon_cache_new_for_path (const gchar *path)
/* Verify cache is uptodate */
if (st.st_mtime < path_st.st_mtime)
{
GTK_NOTE (ICONTHEME,
g_print ("cache outdated\n"));
GTK_NOTE (ICONTHEME, g_print ("cache outdated\n"));
goto done;
}
......@@ -133,7 +132,7 @@ _gtk_icon_cache_new_for_path (const gchar *path)
goto done;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_ICONTHEME)
if (GTK_DEBUG_CHECK (ICONTHEME))
{
CacheInfo info;
......
......@@ -185,7 +185,7 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
double red, green, blue, alpha;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_NO_PIXEL_CACHE)
if (GTK_DEBUG_CHECK (NO_PIXEL_CACHE))
return;
#endif
......@@ -363,7 +363,7 @@ _gtk_pixel_cache_repaint (GtkPixelCache *cache,
cairo_restore (backing_cr);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_PIXEL_CACHE)
if (GTK_DEBUG_CHECK (PIXEL_CACHE))
{
GdkRGBA colors[] = {
{ 1, 0, 0, 0.08},
......
......@@ -491,7 +491,8 @@ gtk_print_job_get_surface (GtkPrintJob *job,
#ifdef G_ENABLE_DEBUG
/* If we are debugging printing don't delete the tmp files */
if (!(gtk_get_debug_flags () & GTK_DEBUG_PRINTING))
if (GTK_DEBUG_CHECK (PRINTING)) ;
else
#endif /* G_ENABLE_DEBUG */
g_unlink (filename);
g_free (filename);
......
......@@ -74,7 +74,7 @@ static void
_gtk_rbnode_free (GtkRBNode *node)
{
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
node->left = (gpointer) 0xdeadbeef;
node->right = (gpointer) 0xdeadbeef;
......@@ -394,7 +394,7 @@ _gtk_rbtree_remove (GtkRBTree *tree)
#ifdef G_ENABLE_DEBUG
GtkRBTree *tmp_tree;
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
_gtk_rbtree_test (G_STRLOC, tree);
#endif
......@@ -415,7 +415,7 @@ _gtk_rbtree_remove (GtkRBTree *tree)
_gtk_rbtree_free (tree);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
_gtk_rbtree_test (G_STRLOC, tmp_tree);
#endif
}
......@@ -431,13 +431,13 @@ _gtk_rbtree_insert_after (GtkRBTree *tree,
gboolean right = TRUE;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("\n\n_gtk_rbtree_insert_after: %p\n", current);
_gtk_rbtree_debug_spew (tree);
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
if (current != NULL && !_gtk_rbtree_is_nil (current->right))
{
......@@ -476,14 +476,14 @@ _gtk_rbtree_insert_after (GtkRBTree *tree,
_gtk_rbtree_insert_fixup (tree, node);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("_gtk_rbtree_insert_after finished...\n");
_gtk_rbtree_debug_spew (tree);
g_print ("\n\n");
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
return node;
}
......@@ -498,13 +498,13 @@ _gtk_rbtree_insert_before (GtkRBTree *tree,
gboolean left = TRUE;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("\n\n_gtk_rbtree_insert_before: %p\n", current);
_gtk_rbtree_debug_spew (tree);
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
if (current != NULL && !_gtk_rbtree_is_nil (current->left))
{
......@@ -544,14 +544,14 @@ _gtk_rbtree_insert_before (GtkRBTree *tree,
_gtk_rbtree_insert_fixup (tree, node);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("_gtk_rbtree_insert_before finished...\n");
_gtk_rbtree_debug_spew (tree);
g_print ("\n\n");
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
return node;
}
......@@ -591,7 +591,7 @@ _gtk_rbtree_node_set_height (GtkRBTree *tree,
gtk_rbnode_adjust (tree, node, 0, 0, diff);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
_gtk_rbtree_test (G_STRLOC, tree);
#endif
}
......@@ -1117,13 +1117,13 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("\n\n_gtk_rbtree_remove_node: %p\n", node);
_gtk_rbtree_debug_spew (tree);
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
/* make sure we're deleting a node that's actually in the tree */
for (x = node; !_gtk_rbtree_is_nil (x->parent); x = x->parent)
......@@ -1131,7 +1131,7 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
g_return_if_fail (x == tree->root);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
_gtk_rbtree_test (G_STRLOC, tree);
#endif
......@@ -1227,14 +1227,14 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
_gtk_rbnode_free (node);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_print ("_gtk_rbtree_remove_node finished...\n");
_gtk_rbtree_debug_spew (tree);
g_print ("\n\n");
_gtk_rbtree_test (G_STRLOC, tree);
}
#endif /* G_ENABLE_DEBUG */
#endif
}
GtkRBNode *
......
......@@ -755,8 +755,10 @@ _gtk_text_btree_delete (GtkTextIter *start,
tree = _gtk_text_iter_get_btree (start);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
/* Broadcast the need for redisplay before we break the iterators */
DV (g_print ("invalidating due to deleting some text (%s)\n", G_STRLOC));
......@@ -1077,8 +1079,10 @@ _gtk_text_btree_delete (GtkTextIter *start,
chars_changed (tree);
segments_changed (tree);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
/* Re-initialize our iterators */
_gtk_text_btree_get_iter_at_line (tree, start, start_line, start_byte_offset);
......@@ -1359,8 +1363,10 @@ find_line_by_y (GtkTextBTree *tree, BTreeView *view,
{
gint current_y = 0;
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
if (node->level == 0)
{
......@@ -2011,8 +2017,10 @@ _gtk_text_btree_tag (const GtkTextIter *start_orig,
queue_tag_redisplay (tree, tag, &start, &end);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
}
......@@ -2736,8 +2744,10 @@ real_set_mark (GtkTextBTree *tree,
iter = *where;
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_iter_check (&iter);
#endif
if (mark != NULL)
{
......@@ -2793,8 +2803,10 @@ real_set_mark (GtkTextBTree *tree,
mark);
}
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_iter_check (&iter);
#endif
/* Link mark into new location */
gtk_text_btree_link_segment (mark, &iter);
......@@ -2808,11 +2820,13 @@ real_set_mark (GtkTextBTree *tree,
redisplay_mark_if_visible (mark);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
{
_gtk_text_iter_check (&iter);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
_gtk_text_btree_check (tree);
}
#endif
return mark;
}
......@@ -4329,8 +4343,10 @@ _gtk_text_line_next_could_contain_tag (GtkTextLine *line,
g_return_val_if_fail (line != NULL, NULL);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
if (tag == NULL)
{
......@@ -4492,8 +4508,10 @@ _gtk_text_line_previous_could_contain_tag (GtkTextLine *line,
g_return_val_if_fail (line != NULL, NULL);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
if (tag == NULL)
{
......@@ -5264,8 +5282,10 @@ _gtk_text_btree_validate (GtkTextBTree *tree,
if (new_height)
*new_height = state.new_height;
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
return TRUE;
}
......@@ -5973,8 +5993,10 @@ post_insert_fixup (GtkTextBTree *tree,
gtk_text_btree_rebalance (tree, node);
}
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
}
static GtkTextTagInfo*
......@@ -6539,8 +6561,10 @@ gtk_text_btree_link_segment (GtkTextLineSegment *seg,
cleanup_line (line);
segments_changed (tree);
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_btree_check (tree);
#endif
}
static void
......@@ -6634,7 +6658,7 @@ _gtk_toggle_segment_check_func (GtkTextLineSegment *segPtr,
/*
* Debug
*/
#ifdef G_ENABLE_DEBUG
static void
gtk_text_btree_node_view_check_consistency (GtkTextBTree *tree,
GtkTextBTreeNode *node,
......@@ -7081,6 +7105,7 @@ _gtk_text_btree_check (GtkTextBTree *tree)
seg->body.chars);
}
}
#endif /* G_ENABLE_DEBUG */
void _gtk_text_btree_spew_line (GtkTextBTree* tree, GtkTextLine* line);
void _gtk_text_btree_spew_segment (GtkTextBTree* tree, GtkTextLineSegment* seg);
......
......@@ -369,7 +369,7 @@ is_segment_start (GtkTextRealIter *real)
static void
check_invariants (const GtkTextIter *iter)
{
if (gtk_get_debug_flags () & GTK_DEBUG_TEXT)
if (GTK_DEBUG_CHECK (TEXT))
_gtk_text_iter_check (iter);
}
#else
......
......@@ -6042,8 +6042,10 @@ cursor_blinks (GtkTextView *text_view)
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
#endif
if (gtk_get_debug_flags () & GTK_DEBUG_UPDATES)
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (UPDATES))
return FALSE;
#endif
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
......
......@@ -192,16 +192,19 @@ static void gtk_tree_store_move (GtkTreeStore *
gboolean before);
#ifdef G_ENABLE_DEBUG
static inline void
validate_tree (GtkTreeStore *tree_store)
{
if (gtk_get_debug_flags () & GTK_DEBUG_TREE)
if (GTK_DEBUG_CHECK (TREE))
{
g_assert (G_NODE (tree_store->priv->root)->parent == NULL);
validate_gnode (G_NODE (tree_store->priv->root));
}
}
#else
#define validate_tree(store)
#endif
G_DEFINE_TYPE_WITH_CODE (GtkTreeStore, gtk_tree_store, G_TYPE_OBJECT,
G_ADD_PRIVATE (GtkTreeStore)
......
......@@ -5839,7 +5839,7 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_GEOMETRY)
if (GTK_DEBUG_CHECK (GEOMETRY))
{
gint depth;
GtkWidget *parent;
......@@ -5901,7 +5901,7 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
}
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_GEOMETRY)
if (GTK_DEBUG_CHECK (GEOMETRY))
{
if ((min_width > real_allocation.width || min_height > real_allocation.height) &&
!GTK_IS_SCROLLABLE (widget))
......@@ -6845,7 +6845,7 @@ _gtk_widget_draw_internal (GtkWidget *widget,
&result);
#ifdef G_ENABLE_DEBUG
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_BASELINES))
if (GTK_DEBUG_CHECK (BASELINES))
{
gint baseline = gtk_widget_get_allocated_baseline (widget);
gint width = gtk_widget_get_allocated_width (widget);
......@@ -15584,7 +15584,7 @@ gtk_widget_set_clip (GtkWidget *widget,
priv = widget->priv;
#ifdef G_ENABLE_DEBUG
if (gtk_get_debug_flags () & GTK_DEBUG_GEOMETRY)
if (GTK_DEBUG_CHECK (GEOMETRY))
{
gint depth;
GtkWidget *parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment