[vlc-devel] [PATCH 2/2] qt4: Replace redundant virtual with Q_DECL_OVERRIDE

Uwe L. Korn uwelk at xhochy.com
Tue Aug 12 16:53:48 CEST 2014


Declaring a virtual function in a subclass as virtual may be a good
documentation that we are overriding a method from the superclass but
has no effect during compilation. With C++11, we can use the override
keyword for this (which will even trigger a compiler error if we try to
override a non-virtual function).

To stay backwards-compatible, we use Qt5's Q_DECL_OVERRIDE macro to
support C++ <11.
---
 modules/gui/qt4/main_interface.hpp | 18 +++++++++---------
 modules/gui/qt4/util/qvlcframe.hpp |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index f19ab0b..fd720e0 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -96,15 +96,15 @@ protected:
 #ifdef _WIN32
     virtual bool winEvent( MSG *, long * );
 #endif
-    virtual void changeEvent( QEvent * );
-    virtual void dropEvent( QDropEvent *);
-    virtual void dragEnterEvent( QDragEnterEvent * );
-    virtual void dragMoveEvent( QDragMoveEvent * );
-    virtual void dragLeaveEvent( QDragLeaveEvent * );
-    virtual void closeEvent( QCloseEvent *);
-    virtual void keyPressEvent( QKeyEvent *);
-    virtual void wheelEvent( QWheelEvent * );
-    virtual bool eventFilter(QObject *, QEvent *);
+    void changeEvent( QEvent * ) Q_DECL_OVERRIDE;
+    void dropEvent( QDropEvent *) Q_DECL_OVERRIDE;
+    void dragEnterEvent( QDragEnterEvent * ) Q_DECL_OVERRIDE;
+    void dragMoveEvent( QDragMoveEvent * ) Q_DECL_OVERRIDE;
+    void dragLeaveEvent( QDragLeaveEvent * ) Q_DECL_OVERRIDE;
+    void closeEvent( QCloseEvent *) Q_DECL_OVERRIDE;
+    void keyPressEvent( QKeyEvent *) Q_DECL_OVERRIDE;
+    void wheelEvent( QWheelEvent * ) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
 
 private:
     /* Main Widgets Creation */
diff --git a/modules/gui/qt4/util/qvlcframe.hpp b/modules/gui/qt4/util/qvlcframe.hpp
index 2747a4a..3706f4d 100644
--- a/modules/gui/qt4/util/qvlcframe.hpp
+++ b/modules/gui/qt4/util/qvlcframe.hpp
@@ -133,7 +133,7 @@ protected:
     {
         hide();
     }
-    virtual void keyPressEvent( QKeyEvent *keyEvent )
+    void keyPressEvent( QKeyEvent *keyEvent ) Q_DECL_OVERRIDE
     {
         if( keyEvent->key() == Qt::Key_Escape )
         {
@@ -171,7 +171,7 @@ protected:
     {
         hide();
     }
-    virtual void keyPressEvent( QKeyEvent *keyEvent )
+    void keyPressEvent( QKeyEvent *keyEvent ) Q_DECL_OVERRIDE
     {
         if( keyEvent->key() == Qt::Key_Escape )
         {
-- 
2.0.4




More information about the vlc-devel mailing list