[vlc-commits] Qt: Remove event deduplication (fix #7390).
Francois Cartegnie
git at videolan.org
Sat Sep 15 14:43:32 CEST 2012
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Sep 15 14:19:43 2012 +0200| [7fab4e77c663e0bcd348fb35170186912145963a] | committer: Francois Cartegnie
Qt: Remove event deduplication (fix #7390).
No way to reproduce bug case.
Fixing by removing all the code.
This reverts commit ddf9e6da14762a84d5c64eecd25015daef388098.
This reverts commit c7ab9f113d6a3e788d05a45ad2ccd31527901d88.
This reverts commit 541c1d97c0087c5de559b9793f42ea698f8c284e.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7fab4e77c663e0bcd348fb35170186912145963a
---
modules/gui/qt4/Modules.am | 3 --
modules/gui/qt4/input_manager.cpp | 19 +--------
modules/gui/qt4/input_manager.hpp | 13 +-----
modules/gui/qt4/util/uniqueevent.cpp | 78 ----------------------------------
modules/gui/qt4/util/uniqueevent.hpp | 57 -------------------------
5 files changed, 4 insertions(+), 166 deletions(-)
diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am
index b88055b..334c534 100644
--- a/modules/gui/qt4/Modules.am
+++ b/modules/gui/qt4/Modules.am
@@ -73,7 +73,6 @@ nodist_SOURCES_qt4 = \
util/qmenuview.moc.cpp \
util/qvlcapp.moc.cpp \
util/pictureflow.moc.cpp \
- util/uniqueevent.moc.cpp \
util/buttons/RoundButton.moc.cpp \
util/buttons/DeckButtonsLayout.moc.cpp \
util/buttons/BrowseButton.moc.cpp \
@@ -313,7 +312,6 @@ SOURCES_qt4 = qt4.cpp \
util/qmenuview.cpp \
util/qt_dirs.cpp \
util/pictureflow.cpp \
- util/uniqueevent.cpp \
util/buttons/BrowseButton.cpp \
util/buttons/DeckButtonsLayout.cpp \
util/buttons/RoundButton.cpp \
@@ -393,7 +391,6 @@ noinst_HEADERS = \
util/qt_dirs.hpp \
util/registry.hpp \
util/pictureflow.hpp \
- util/uniqueevent.hpp \
util/singleton.hpp \
util/buttons/RoundButton.hpp \
util/buttons/DeckButtonsLayout.hpp \
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index db05853..5107f5a 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -87,14 +87,12 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
timeA = 0;
timeB = 0;
f_cache = -1.; /* impossible initial value, different from all */
- rateLimitedEventPoster = new RateLimitedEventPoster();
registerAndCheckEventIds( IMEvent::PositionUpdate, IMEvent::FullscreenControlPlanHide );
registerAndCheckEventIds( PLEvent::PLItemAppended, PLEvent::PLEmpty );
}
InputManager::~InputManager()
{
- delete rateLimitedEventPoster;
delInput();
}
@@ -179,11 +177,6 @@ void InputManager::delInput()
emit cachingChanged( 1 );
}
-void InputManager::postUniqueEvent( QObject *target, UniqueEvent *e )
-{
- rateLimitedEventPoster->postEvent( e, target );
-}
-
/* Convert the event from the callbacks in actions */
void InputManager::customEvent( QEvent *event )
{
@@ -300,7 +293,7 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
input_item_t *p_item = static_cast<input_item_t *>(newval.p_address);
IMEvent *event = new IMEvent( IMEvent::ItemChanged, p_item );
- im->postUniqueEvent( im, event );
+ QApplication::postEvent( im, event );
return VLC_SUCCESS;
}
@@ -311,7 +304,6 @@ static int InputEvent( vlc_object_t *p_this, const char *,
InputManager *im = (InputManager*)param;
IMEvent *event;
- bool b_unified = false;
switch( newval.i_int )
{
@@ -350,14 +342,12 @@ static int InputEvent( vlc_object_t *p_this, const char *,
break;
case INPUT_EVENT_ITEM_META: /* Codec MetaData + Art */
- b_unified = true;
event = new IMEvent( IMEvent::MetaChanged );
break;
case INPUT_EVENT_ITEM_INFO: /* Codec Info */
event = new IMEvent( IMEvent::InfoChanged );
break;
case INPUT_EVENT_ITEM_NAME:
- b_unified = true;
event = new IMEvent( IMEvent::NameChanged );
break;
@@ -398,12 +388,7 @@ static int InputEvent( vlc_object_t *p_this, const char *,
}
if( event )
- {
- if ( b_unified )
- im->postUniqueEvent( im, event );
- else
- QApplication::postEvent( im, event );
- }
+ QApplication::postEvent( im, event );
return VLC_SUCCESS;
}
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index fd1e967..33648a3 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -33,7 +33,6 @@
#include "qt4.hpp"
#include "util/singleton.hpp"
-#include "util/uniqueevent.hpp"
#include "variables.hpp"
#include <QObject>
@@ -44,7 +43,7 @@ enum { NORMAL, /* loop: 0, repeat: 0 */
REPEAT_ALL,/* loop: 1, repeat: 0 */
};
-class IMEvent : public UniqueEvent
+class IMEvent : public QEvent
{
public:
enum event_types {
@@ -78,7 +77,7 @@ public:
};
IMEvent( event_types type, input_item_t *p_input = NULL )
- : UniqueEvent( (QEvent::Type)(type) )
+ : QEvent( (QEvent::Type)(type) )
{
if( (p_item = p_input) != NULL )
vlc_gc_incref( p_item );
@@ -92,12 +91,6 @@ public:
input_item_t *item() const { return p_item; };
- virtual bool equals(UniqueEvent *e) const
- {
- IMEvent *ev = static_cast<IMEvent *>(e);
- return ( ev->item() == p_item && ev->type() == type() );
- }
-
private:
input_item_t *p_item;
};
@@ -153,7 +146,6 @@ public:
QString getName() { return oldName; }
static const QString decodeArtURL( input_item_t *p_item );
- void postUniqueEvent( QObject *, UniqueEvent * );
private:
intf_thread_t *p_intf;
@@ -169,7 +161,6 @@ private:
mtime_t timeA, timeB;
void customEvent( QEvent * );
- RateLimitedEventPoster *rateLimitedEventPoster;
void addCallbacks();
void delCallbacks();
diff --git a/modules/gui/qt4/util/uniqueevent.cpp b/modules/gui/qt4/util/uniqueevent.cpp
deleted file mode 100644
index 7dade60..0000000
--- a/modules/gui/qt4/util/uniqueevent.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*****************************************************************************
- * Copyright © 2012 VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include "uniqueevent.hpp"
-#include "qt4.hpp"
-
-#include <QTimer>
-#include <QApplication>
-#include <QMutex>
-
-RateLimitedEventPoster::RateLimitedEventPoster( int i_millisec_interval )
-{
- timer = new QTimer();
- mutex = new QMutex();
- timer->setSingleShot( true );
- /* Assuming a 24fps event loop, delays at least events to the next frame */
- if ( i_millisec_interval < 1 )
- i_millisec_interval = 1000 / 48;
- timer->setInterval( i_millisec_interval );
- CONNECT( timer, timeout(), this, commit() );
-}
-
-RateLimitedEventPoster::~RateLimitedEventPoster()
-{
- timer->stop();
- commit();
- delete timer;
- delete mutex;
-}
-
-void RateLimitedEventPoster::postEvent( UniqueEvent *e, QObject *target )
-{
- event_tuple newtuple = { target, e };
- mutex->lock();
- foreach( const event_tuple & tuple, eventsList )
- {
- if ( target == tuple.target && tuple.event->equals( e ) )
- {
- delete e;
- mutex->unlock();
- return;
- }
- }
- eventsList << newtuple;
- mutex->unlock();
- if ( eventsList.count() >= 100 ) /* limit lookup time */
- {
- timer->stop();
- commit();
- }
- if ( !timer->isActive() ) timer->start();
-}
-
-void RateLimitedEventPoster::commit()
-{
- mutex->lock();
- foreach( const event_tuple & tuple, eventsList )
- {
- QApplication::postEvent( tuple.target, tuple.event );
- }
- eventsList.clear();
- mutex->unlock();
-}
diff --git a/modules/gui/qt4/util/uniqueevent.hpp b/modules/gui/qt4/util/uniqueevent.hpp
deleted file mode 100644
index 5065441..0000000
--- a/modules/gui/qt4/util/uniqueevent.hpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * Copyright © 2012 VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-#ifndef UNIQUEEVENT_HPP
-#define UNIQUEEVENT_HPP
-
-#include <QObject>
-#include <QEvent>
-#include <QList>
-class QTimer;
-class QMutex;
-
-class UniqueEvent : public QEvent
-{
-public:
- UniqueEvent( QEvent::Type type ) : QEvent( type ) {};
- virtual bool equals( UniqueEvent *e ) const = 0;
-};
-
-class RateLimitedEventPoster : public QObject
-{
- Q_OBJECT
-
-public:
- RateLimitedEventPoster( int i_millisec_interval = -1 );
- ~RateLimitedEventPoster();
- void postEvent( UniqueEvent *e, QObject *target );
-
-private slots:
- void commit();
-
-private:
- struct event_tuple
- {
- QObject *target;
- UniqueEvent *event;
- };
- QList<event_tuple> eventsList;
- QTimer *timer;
- QMutex *mutex;
-};
-
-#endif // UNIQUEEVENT_HPP
More information about the vlc-commits
mailing list