[vlc-commits] gui/qt: fix invalid static_cast

Filip Roséen git at videolan.org
Mon Sep 26 09:05:22 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Mon Sep 26 03:22:10 2016 +0200| [f2b8777b6ed97eeaa711eef8f950d173182e3412] | committer: Thomas Guillem

gui/qt: fix invalid static_cast

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.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f2b8777b6ed97eeaa711eef8f950d173182e3412
---

 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



More information about the vlc-commits mailing list