[gtkmm] Custom cell renderer, seg fault & core dump on widget.get_default_colormap ()



I'm trying to implement a custom treeview cell renderer and I'm
following the example in the distribution: 
examples/cellrenderercustom/cellrenderertoggle.cc

I have:

void MyCellRenderer::drawMyArea( 
    const Glib::RefPtr<Gdk::Window>&     window,      
    Gtk::Widget&     widget,      
    int     x,      
    int     y,      
    int     width,      
    int     height     )
{
// lines like those in the example except those referrring to style 
// and shadow since I'm doing the drawing myself, and then:

    colormap=widget.get_default_colormap ();

// intending later to do things like:
//    colormap->alloc_color(black_);
}

This is essentially all right now, and if the line above is commented
out, my problem does not occur.

The problem:

This is used for one column of my table (treeview) and when my table is
scrolled side to side over and over and over, and the column goes in and
out of view over and over, I can get it to seg fault everytime.

There were other lines following this that drew in that cell, but I
commented them out to narrow it down to this as the problem line.  I get
the colormap, do things with colors, draw rects, points, etc.  But, all
that is commented out right now.  That all works fine, except for this
problem.

I have looked for NULL pointers on widget and window (and their
gobj()'s), but is there something I should be checking for before
calling widget.get_default_colormap()?  Or is there something else I
should do instead of calling that?

Or is there a better way to do what I'm trying to do?

Thanks,

Mark

PS  Some messages I've gotten (but sometimes I get none, and sometimes I
get different ones):
GLib-GObject-CRITICAL **: file gobject.c: line 1289 (g_object_ref):
assertion `G_IS_OBJECT (object)' failed

GLib-GObject-CRITICAL **: file gobject.c: line 1307 (g_object_unref):
assertion `G_IS_OBJECT (object)' failed

GLib-GObject-CRITICAL **: file gobject.c: line 1307 (g_object_unref):
assertion `G_IS_OBJECT (object)' failed

Gdk-CRITICAL **: file gdkdraw.c: line 227 (gdk_drawable_set_colormap):
assertion `cmap == NULL || gdk_drawable_get_depth (drawable) ==
cmap->visual->depth' failed

GLib-GObject-CRITICAL **: file gobject.c: line 1289 (g_object_ref):
assertion `G_IS_OBJECT (object)' failed

GLib-GObject-CRITICAL **: file gobject.c: line 1307 (g_object_unref):
assertion `G_IS_OBJECT (object)' failed

Gdk-CRITICAL **: file gdkdraw.c: line 227 (gdk_drawable_set_colormap):
assertion `cmap == NULL || gdk_drawable_get_depth (drawable) ==
cmap->visual->depth' failed

Gdk-CRITICAL **: file gdkcolor-x11.c: line 1039
(gdk_colormap_query_color): assertion `GDK_IS_COLORMAP (colormap)'
failed




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]