]> sigrok.org Git - pulseview.git/commitdiff
Fix #849 by making sure no references to the DecodeTrace instance remain
authorSoeren Apel <redacted>
Thu, 24 Nov 2016 17:42:24 +0000 (18:42 +0100)
committerSoeren Apel <redacted>
Sun, 4 Dec 2016 13:37:38 +0000 (14:37 +0100)
pv/session.cpp
pv/view/viewwidget.cpp

index 3c5bcc426cd750fcca98ab1a56c9b97c70a86009..2d7918b87c9ef347c7ca4392b8555d4d44203a38 100644 (file)
@@ -585,8 +585,12 @@ bool Session::add_decoder(srd_decoder *const dec)
 
 void Session::remove_decode_signal(shared_ptr<data::SignalBase> signalbase)
 {
+       signalbases_.erase(signalbase);
+
        for (std::shared_ptr<views::ViewBase> view : views_)
                view->remove_decode_signal(signalbase);
+
+       signals_changed();
 }
 #endif
 
index 3bd8c6b9d919522909a3578fe69240767f2e7788..8a7a728521ff49fb8f28b19d7412d126c8d90a58 100644 (file)
@@ -252,16 +252,23 @@ void ViewWidget::mousePressEvent(QMouseEvent *event)
 {
        assert(event);
 
-       mouse_down_point_ = event->pos();
-       mouse_down_item_ = get_mouse_over_item(event->pos());
-
-       if (event->button() & Qt::LeftButton)
+       /* Ignore right click events as they will open context menus when
+        * used on trace labels. Those menus prevent ViewWidget::mouseReleaseEvent()
+        * to be triggered upon button release, making mouse_down_item_
+        * hold the last reference to a view item that might have been deleted
+        * from the context menu, preventing it from being freed as intended.
+        */
+       if (event->button() & Qt::LeftButton) {
+               mouse_down_point_ = event->pos();
+               mouse_down_item_ = get_mouse_over_item(event->pos());
                mouse_left_press_event(event);
+       }
 }
 
 void ViewWidget::mouseReleaseEvent(QMouseEvent *event)
 {
        assert(event);
+
        if (event->button() & Qt::LeftButton)
                mouse_left_release_event(event);