fix crash when cleaning up canvas items

Backport from Mixbus. In Ardour this does not currently matter
since there is no top-level canvas destroyed top-down.

...
Editor::session_going_away
MixerStrip::~MixerStrip
MixbusStripCanvas::~MixbusStripCanvas
ArdourCanvas::GtkCanvas::~GtkCanvas
ArdourCanvas::Canvas::~Canvas
ArdourCanvas::Root::~Root
ArdourCanvas::Container::~Container
ArdourCanvas::Item::~Item
ArdourCanvas::Item::clear_items
GtkCanvas::item_going_away()
queue_draw_item_area()

..expose can take place async to garbage collection: crash in one of the
items.
This commit is contained in:
Robin Gareus 2015-11-02 05:15:55 +01:00
parent 84d44eb5a3
commit 160b24b137
2 changed files with 12 additions and 0 deletions

View file

@ -389,6 +389,7 @@ GtkCanvas::GtkCanvas ()
, _single_exposure (1)
, current_tooltip_item (0)
, tooltip_window (0)
, _in_dtor (false)
{
/* these are the events we want to know about */
add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK |
@ -779,6 +780,10 @@ GtkCanvas::on_size_allocate (Gtk::Allocation& a)
bool
GtkCanvas::on_expose_event (GdkEventExpose* ev)
{
if (_in_dtor) {
return true;
}
#ifdef OPTIONAL_CAIRO_IMAGE_SURFACE
Cairo::RefPtr<Cairo::Context> draw_context;
Cairo::RefPtr<Cairo::Context> window_context;
@ -1039,6 +1044,10 @@ GtkCanvas::on_leave_notify_event (GdkEventCrossing* ev)
void
GtkCanvas::request_redraw (Rect const & request)
{
if (_in_dtor) {
return;
}
Rect real_area;
Coord const w = width ();

View file

@ -172,6 +172,7 @@ class LIBCANVAS_API GtkCanvas : public Canvas, public Gtk::EventBox
{
public:
GtkCanvas ();
~GtkCanvas () { _in_dtor = true ; }
void request_redraw (Rect const &);
void request_size (Duple);
@ -238,6 +239,8 @@ private:
bool show_tooltip ();
void hide_tooltip ();
bool really_start_tooltip_timeout ();
bool _in_dtor;
};
/** A GTK::Alignment with a GtkCanvas inside it plus some Gtk::Adjustments for