Very strange issue with multiple drawing areas



Hi all.

I'm using a DrawingArea to render a graph. I then thought it would be
great to have multiple graphs, side-by-side, for different dates. So I
now create drawing areas in a loop, one for each day selected. However
*most* things are rendering to the 1st drawing area, and I've spent a
day looking at my code, and don't think I have a bug anywhere.

Each drawing area is added to a box:

$self->{builder}->get_object( "graph_box" )->pack_start(
$drawing_area, 1, 1, 0 );

The 'draw' signal is being set:

$drawing_area->signal_connect( draw => sub { $self->render_graph( @_,
$date ) } );

This is being fired for all drawing areas connected, and I get the
correct $date being passed in. But all the graphing occurs in 1
drawing area. Interestingly, I have another method for rendering text,
and *this* is correctly rendering on each drawing area. But both this
method, and the method rendering the graphs use the $cairo_context
being passed into render_graph, eg:

sub render_graph {

    my ( $self, $widget, $cairo_context, $date ) = @_;

    ...

}

Lastly, while I see $widget changes for each drawing area,
$cairo_context is actually the same *every* time. I would have
expected this to change. Why isn't it?

I can't see how I could have possibly mixed things up, as the
$cairo_context is automatically passed in on the 'draw' event for each
drawing area. I'm not doing anything weird like storing cairo contexts
in global variables. I could post the code if someone is interested,
but it's pretty big these days, and requires a database to pull data
from.

Can anyone think of a reason why I'm seeing these issues? Is there
some limitation on only having 1 drawing area?

Dan


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