Commit 7fab4e77 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: Remove event deduplication (fix #7390).

No way to reproduce bug case.
Fixing by removing all the code.

This reverts commit ddf9e6da.
This reverts commit c7ab9f11.
This reverts commit 541c1d97.
parent 417738d2
No related merge requests found
...@@ -73,7 +73,6 @@ nodist_SOURCES_qt4 = \ ...@@ -73,7 +73,6 @@ nodist_SOURCES_qt4 = \
util/qmenuview.moc.cpp \ util/qmenuview.moc.cpp \
util/qvlcapp.moc.cpp \ util/qvlcapp.moc.cpp \
util/pictureflow.moc.cpp \ util/pictureflow.moc.cpp \
util/uniqueevent.moc.cpp \
util/buttons/RoundButton.moc.cpp \ util/buttons/RoundButton.moc.cpp \
util/buttons/DeckButtonsLayout.moc.cpp \ util/buttons/DeckButtonsLayout.moc.cpp \
util/buttons/BrowseButton.moc.cpp \ util/buttons/BrowseButton.moc.cpp \
...@@ -313,7 +312,6 @@ SOURCES_qt4 = qt4.cpp \ ...@@ -313,7 +312,6 @@ SOURCES_qt4 = qt4.cpp \
util/qmenuview.cpp \ util/qmenuview.cpp \
util/qt_dirs.cpp \ util/qt_dirs.cpp \
util/pictureflow.cpp \ util/pictureflow.cpp \
util/uniqueevent.cpp \
util/buttons/BrowseButton.cpp \ util/buttons/BrowseButton.cpp \
util/buttons/DeckButtonsLayout.cpp \ util/buttons/DeckButtonsLayout.cpp \
util/buttons/RoundButton.cpp \ util/buttons/RoundButton.cpp \
...@@ -393,7 +391,6 @@ noinst_HEADERS = \ ...@@ -393,7 +391,6 @@ noinst_HEADERS = \
util/qt_dirs.hpp \ util/qt_dirs.hpp \
util/registry.hpp \ util/registry.hpp \
util/pictureflow.hpp \ util/pictureflow.hpp \
util/uniqueevent.hpp \
util/singleton.hpp \ util/singleton.hpp \
util/buttons/RoundButton.hpp \ util/buttons/RoundButton.hpp \
util/buttons/DeckButtonsLayout.hpp \ util/buttons/DeckButtonsLayout.hpp \
......
...@@ -87,14 +87,12 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : ...@@ -87,14 +87,12 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
timeA = 0; timeA = 0;
timeB = 0; timeB = 0;
f_cache = -1.; /* impossible initial value, different from all */ f_cache = -1.; /* impossible initial value, different from all */
rateLimitedEventPoster = new RateLimitedEventPoster();
registerAndCheckEventIds( IMEvent::PositionUpdate, IMEvent::FullscreenControlPlanHide ); registerAndCheckEventIds( IMEvent::PositionUpdate, IMEvent::FullscreenControlPlanHide );
registerAndCheckEventIds( PLEvent::PLItemAppended, PLEvent::PLEmpty ); registerAndCheckEventIds( PLEvent::PLItemAppended, PLEvent::PLEmpty );
} }
InputManager::~InputManager() InputManager::~InputManager()
{ {
delete rateLimitedEventPoster;
delInput(); delInput();
} }
...@@ -179,11 +177,6 @@ void InputManager::delInput() ...@@ -179,11 +177,6 @@ void InputManager::delInput()
emit cachingChanged( 1 ); emit cachingChanged( 1 );
} }
void InputManager::postUniqueEvent( QObject *target, UniqueEvent *e )
{
rateLimitedEventPoster->postEvent( e, target );
}
/* Convert the event from the callbacks in actions */ /* Convert the event from the callbacks in actions */
void InputManager::customEvent( QEvent *event ) void InputManager::customEvent( QEvent *event )
{ {
...@@ -300,7 +293,7 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -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); input_item_t *p_item = static_cast<input_item_t *>(newval.p_address);
IMEvent *event = new IMEvent( IMEvent::ItemChanged, p_item ); IMEvent *event = new IMEvent( IMEvent::ItemChanged, p_item );
im->postUniqueEvent( im, event ); QApplication::postEvent( im, event );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -311,7 +304,6 @@ static int InputEvent( vlc_object_t *p_this, const char *, ...@@ -311,7 +304,6 @@ static int InputEvent( vlc_object_t *p_this, const char *,
InputManager *im = (InputManager*)param; InputManager *im = (InputManager*)param;
IMEvent *event; IMEvent *event;
bool b_unified = false;
switch( newval.i_int ) switch( newval.i_int )
{ {
...@@ -350,14 +342,12 @@ static int InputEvent( vlc_object_t *p_this, const char *, ...@@ -350,14 +342,12 @@ static int InputEvent( vlc_object_t *p_this, const char *,
break; break;
case INPUT_EVENT_ITEM_META: /* Codec MetaData + Art */ case INPUT_EVENT_ITEM_META: /* Codec MetaData + Art */
b_unified = true;
event = new IMEvent( IMEvent::MetaChanged ); event = new IMEvent( IMEvent::MetaChanged );
break; break;
case INPUT_EVENT_ITEM_INFO: /* Codec Info */ case INPUT_EVENT_ITEM_INFO: /* Codec Info */
event = new IMEvent( IMEvent::InfoChanged ); event = new IMEvent( IMEvent::InfoChanged );
break; break;
case INPUT_EVENT_ITEM_NAME: case INPUT_EVENT_ITEM_NAME:
b_unified = true;
event = new IMEvent( IMEvent::NameChanged ); event = new IMEvent( IMEvent::NameChanged );
break; break;
...@@ -398,12 +388,7 @@ static int InputEvent( vlc_object_t *p_this, const char *, ...@@ -398,12 +388,7 @@ static int InputEvent( vlc_object_t *p_this, const char *,
} }
if( event ) if( event )
{
if ( b_unified )
im->postUniqueEvent( im, event );
else
QApplication::postEvent( im, event ); QApplication::postEvent( im, event );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "util/singleton.hpp" #include "util/singleton.hpp"
#include "util/uniqueevent.hpp"
#include "variables.hpp" #include "variables.hpp"
#include <QObject> #include <QObject>
...@@ -44,7 +43,7 @@ enum { NORMAL, /* loop: 0, repeat: 0 */ ...@@ -44,7 +43,7 @@ enum { NORMAL, /* loop: 0, repeat: 0 */
REPEAT_ALL,/* loop: 1, repeat: 0 */ REPEAT_ALL,/* loop: 1, repeat: 0 */
}; };
class IMEvent : public UniqueEvent class IMEvent : public QEvent
{ {
public: public:
enum event_types { enum event_types {
...@@ -78,7 +77,7 @@ public: ...@@ -78,7 +77,7 @@ public:
}; };
IMEvent( event_types type, input_item_t *p_input = NULL ) IMEvent( event_types type, input_item_t *p_input = NULL )
: UniqueEvent( (QEvent::Type)(type) ) : QEvent( (QEvent::Type)(type) )
{ {
if( (p_item = p_input) != NULL ) if( (p_item = p_input) != NULL )
vlc_gc_incref( p_item ); vlc_gc_incref( p_item );
...@@ -92,12 +91,6 @@ public: ...@@ -92,12 +91,6 @@ public:
input_item_t *item() const { return p_item; }; 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: private:
input_item_t *p_item; input_item_t *p_item;
}; };
...@@ -153,7 +146,6 @@ public: ...@@ -153,7 +146,6 @@ public:
QString getName() { return oldName; } QString getName() { return oldName; }
static const QString decodeArtURL( input_item_t *p_item ); static const QString decodeArtURL( input_item_t *p_item );
void postUniqueEvent( QObject *, UniqueEvent * );
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -169,7 +161,6 @@ private: ...@@ -169,7 +161,6 @@ private:
mtime_t timeA, timeB; mtime_t timeA, timeB;
void customEvent( QEvent * ); void customEvent( QEvent * );
RateLimitedEventPoster *rateLimitedEventPoster;
void addCallbacks(); void addCallbacks();
void delCallbacks(); void delCallbacks();
......
/*****************************************************************************
* 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();
}
/*****************************************************************************
* 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
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