[vlc-devel] [PATCH] gui/qt: fix invalid static_cast

Filip Roséen filip at atch.se
Mon Sep 26 03:22:10 CEST 2016


The dynamic type of the object referred to by "event" is not
QMouseEvent if "event->type()" is Event::Leave.

The previous implementation would unconditionally refer to the object
as-if it was a QMouseEvent when it is simply a QEvent; causing
undefined-behavior.
---
 modules/gui/qt/util/input_slider.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt/util/input_slider.cpp b/modules/gui/qt/util/input_slider.cpp
index 6fa7f46..08638e3 100644
--- a/modules/gui/qt/util/input_slider.cpp
+++ b/modules/gui/qt/util/input_slider.cpp
@@ -475,17 +475,24 @@ bool SeekSlider::eventFilter( QObject *obj, QEvent *event )
 {
     if( obj == mTimeTooltip )
     {
+        if( event->type() == QEvent::MouseMove )
+        {
+            QMouseEvent* mev = static_cast<QMouseEvent*>( event );
+
+            if( rect().contains( mapFromGlobal( mev->globalPos() ) ) )
+                return false;
+        }
+
         if( event->type() == QEvent::Leave ||
             event->type() == QEvent::MouseMove )
         {
-            QMouseEvent *e = static_cast<QMouseEvent*>( event );
-            if( !rect().contains( mapFromGlobal( e->globalPos() ) ) )
-                mTimeTooltip->hide();
+            mTimeTooltip->hide();
         }
+
         return false;
     }
-    else
-        return QSlider::eventFilter( obj, event );
+
+    return QSlider::eventFilter( obj, event );
 }
 
 QSize SeekSlider::sizeHint() const
-- 
2.10.0



More information about the vlc-devel mailing list