Commit 6b88089b authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: Queue toolbar rebuild as event instead of delaying popups's deletion

(fix #7016)

This reverts commit 6f1af24d.
This reverts commit e5462dbd.
parent d5c46557
...@@ -75,6 +75,9 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable, ...@@ -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, vlc_value_t old_val, vlc_value_t new_val,
void *param ); void *param );
const QEvent::Type MainInterface::ToolbarsNeedRebuild =
(QEvent::Type)QEvent::registerEventType();
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{ {
/* Variables initialisation */ /* Variables initialisation */
...@@ -217,7 +220,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -217,7 +220,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
this, setVideoFullScreen( bool ) ); this, setVideoFullScreen( bool ) );
} }
CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() ); CONNECT( THEDP, toolBarConfUpdated(), this, toolBarConfUpdated() );
installEventFilter( this );
CONNECT( this, askToQuit(), THEDP, quit() ); CONNECT( this, askToQuit(), THEDP, quit() );
...@@ -1337,6 +1341,22 @@ void MainInterface::closeEvent( QCloseEvent *e ) ...@@ -1337,6 +1341,22 @@ void MainInterface::closeEvent( QCloseEvent *e )
e->accept(); 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 ) void MainInterface::setInterfaceFullScreen( bool fs )
{ {
if( fs ) if( fs )
......
...@@ -61,7 +61,6 @@ enum { ...@@ -61,7 +61,6 @@ enum {
CONTROLS_ADVANCED = 0x4, CONTROLS_ADVANCED = 0x4,
}; };
class MainInterface : public QVLCMW class MainInterface : public QVLCMW
{ {
Q_OBJECT Q_OBJECT
...@@ -73,6 +72,8 @@ public: ...@@ -73,6 +72,8 @@ public:
MainInterface( intf_thread_t *); MainInterface( intf_thread_t *);
virtual ~MainInterface(); virtual ~MainInterface();
static const QEvent::Type ToolbarsNeedRebuild;
/* Video requests from core */ /* Video requests from core */
WId getVideo( int *pi_x, int *pi_y, WId getVideo( int *pi_x, int *pi_y,
unsigned int *pi_width, unsigned int *pi_height ); unsigned int *pi_width, unsigned int *pi_height );
...@@ -101,6 +102,7 @@ protected: ...@@ -101,6 +102,7 @@ protected:
virtual void closeEvent( QCloseEvent *); virtual void closeEvent( QCloseEvent *);
virtual void keyPressEvent( QKeyEvent *); virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * ); virtual void wheelEvent( QWheelEvent * );
virtual bool eventFilter(QObject *, QEvent *);
private: private:
/* Main Widgets Creation */ /* Main Widgets Creation */
...@@ -205,6 +207,7 @@ public slots: ...@@ -205,6 +207,7 @@ public slots:
void emitRaise(); void emitRaise();
void reloadPrefs(); void reloadPrefs();
void toolBarConfUpdated();
private slots: private slots:
void debug(); void debug();
......
...@@ -769,8 +769,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent ) ...@@ -769,8 +769,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
*****************************************************************************/ *****************************************************************************/
#define POPUP_BOILERPLATE \ #define POPUP_BOILERPLATE \
static QMenu* menu = NULL; \ static QMenu* menu = NULL; \
if ( menu ) menu->deleteLater(); /* Ensure it is deleted after processing events */\ delete menu; menu = NULL; \
menu = NULL; /* or we might crash on an incoming mouseup event */\
if( !show ) \ if( !show ) \
return; \ return; \
QVector<vlc_object_t *> objects; \ QVector<vlc_object_t *> objects; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment