license: remove FSF postal address from boiler plate license text
[pulseview.git] / pv / view / viewwidget.cpp
index 3bd8c6b9d919522909a3578fe69240767f2e7788..ce5c27a83dce2a3c6784dcda17e5d0b2e018b9b7 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <QApplication>
@@ -252,16 +251,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);