[vlc-commits] Qt: Queue toolbar rebuild as event instead of delaying popups's deletion

Francois Cartegnie git at videolan.org
Sun Jul 1 16:02:13 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jun 28 13:03:04 2012 +0200| [6b88089ba6c6c4c8814b82e5921dbbf159de2619] | committer: Francois Cartegnie

Qt: Queue toolbar rebuild as event instead of delaying popups's deletion
(fix #7016)

This reverts commit 6f1af24d75fd36050d8f3a1a4c7369067e90898f.
This reverts commit e5462dbd3a789e15278afd642833788a8a491724.

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

 modules/gui/qt4/main_interface.cpp |   22 +++++++++++++++++++++-
 modules/gui/qt4/main_interface.hpp |    5 ++++-
 modules/gui/qt4/menus.cpp          |    3 +--
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index c02aca5..be15db0 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -75,6 +75,9 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
                            vlc_value_t old_val, vlc_value_t new_val,
                            void *param );
 
+const QEvent::Type MainInterface::ToolbarsNeedRebuild =
+        (QEvent::Type)QEvent::registerEventType();
+
 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     /* Variables initialisation */
@@ -217,7 +220,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
                  this, setVideoFullScreen( bool ) );
     }
 
-    CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
+    CONNECT( THEDP, toolBarConfUpdated(), this, toolBarConfUpdated() );
+    installEventFilter( this );
 
     CONNECT( this, askToQuit(), THEDP, quit() );
 
@@ -1337,6 +1341,22 @@ void MainInterface::closeEvent( QCloseEvent *e )
     e->accept();
 }
 
+bool MainInterface::eventFilter( QObject *obj, QEvent *event )
+{
+    if ( event->type() == MainInterface::ToolbarsNeedRebuild ) {
+        event->accept();
+        recreateToolbars();
+        return true;
+    } else {
+        return QObject::eventFilter( obj, event );
+    }
+}
+
+void MainInterface::toolBarConfUpdated()
+{
+    QApplication::postEvent( this, new QEvent( MainInterface::ToolbarsNeedRebuild ) );
+}
+
 void MainInterface::setInterfaceFullScreen( bool fs )
 {
     if( fs )
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 2b4bb26..78745ce 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -61,7 +61,6 @@ enum {
     CONTROLS_ADVANCED = 0x4,
 };
 
-
 class MainInterface : public QVLCMW
 {
     Q_OBJECT
@@ -73,6 +72,8 @@ public:
     MainInterface( intf_thread_t *);
     virtual ~MainInterface();
 
+    static const QEvent::Type ToolbarsNeedRebuild;
+
     /* Video requests from core */
     WId  getVideo( int *pi_x, int *pi_y,
                   unsigned int *pi_width, unsigned int *pi_height );
@@ -101,6 +102,7 @@ protected:
     virtual void closeEvent( QCloseEvent *);
     virtual void keyPressEvent( QKeyEvent *);
     virtual void wheelEvent( QWheelEvent * );
+    virtual bool eventFilter(QObject *, QEvent *);
 
 private:
     /* Main Widgets Creation */
@@ -205,6 +207,7 @@ public slots:
     void emitRaise();
 
     void reloadPrefs();
+    void toolBarConfUpdated();
 
 private slots:
     void debug();
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index d736ea4..18bb5ca 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -769,8 +769,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
  *****************************************************************************/
 #define POPUP_BOILERPLATE \
     static QMenu* menu = NULL;  \
-    if ( menu ) menu->deleteLater(); /* Ensure it is deleted after processing events */\
-    menu = NULL;                    /* or we might crash on an incoming mouseup event */\
+    delete menu; menu = NULL; \
     if( !show ) \
         return; \
     QVector<vlc_object_t *> objects; \



More information about the vlc-commits mailing list