Commit ba78a1fe authored by François Cartegnie's avatar François Cartegnie 🤞

Qt: rate limit EPG updates

As we don't have discrete updates due to use of input variable
for events, we're updating far too many times on EPG tables updates,
reprocessing the whole EPG set. This is mainly the performance
issue with large EPG updates.

Also no longer updates internal event storage when hidden.
parent 5242884a
......@@ -76,7 +76,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
layout->addWidget( descBox );
CONNECT( epg, itemSelectionChanged( EPGItem *), this, displayEvent( EPGItem *) );
CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
CONNECT( THEMIM->getIM(), epgChanged(), this, scheduleUpdate() );
CONNECT( THEMIM, inputChanged( bool ), this, updateInfos() );
QDialogButtonBox *buttonsBox = new QDialogButtonBox( this );
......@@ -94,8 +94,8 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
timer = new QTimer( this );
timer->setSingleShot( true );
timer->setInterval( 1000 * 60 );
CONNECT( timer, timeout(), this, updateInfos() );
timer->setInterval( 5000 );
CONNECT( timer, timeout(), this, timeout() );
updateInfos();
restoreWidgetPosition( "EPGDialog", QSize( 650, 450 ) );
......@@ -106,6 +106,25 @@ EpgDialog::~EpgDialog()
saveWidgetPosition( "EPGDialog" );
}
void EpgDialog::showEvent(QShowEvent *)
{
scheduleUpdate();
}
void EpgDialog::timeout()
{
if( !isVisible() )
scheduleUpdate();
else
updateInfos();
}
void EpgDialog::scheduleUpdate()
{
if( !timer->isActive() )
timer->start( 5000 );
}
void EpgDialog::displayEvent( EPGItem *epgItem )
{
if( !epgItem ) return;
......@@ -124,7 +143,6 @@ void EpgDialog::displayEvent( EPGItem *epgItem )
void EpgDialog::updateInfos()
{
timer->stop();
input_item_t *p_input_item = NULL;
playlist_t *p_playlist = THEPL;
input_thread_t *p_input_thread = playlist_CurrentInput( p_playlist ); /* w/hold */
......@@ -139,7 +157,6 @@ void EpgDialog::updateInfos()
{
epg->updateEPG( p_input_item );
vlc_gc_decref( p_input_item );
if ( isVisible() ) timer->start();
}
}
}
......@@ -36,6 +36,9 @@ class EPGWidget;
class EpgDialog : public QVLCFrame, public Singleton<EpgDialog>
{
Q_OBJECT
protected:
virtual void showEvent(QShowEvent * event) Q_DECL_OVERRIDE;
private:
EpgDialog( intf_thread_t * );
virtual ~EpgDialog();
......@@ -48,8 +51,10 @@ private:
friend class Singleton<EpgDialog>;
private slots:
void displayEvent( EPGItem * );
void scheduleUpdate();
void updateInfos();
void timeout();
void displayEvent( EPGItem * );
};
#endif
......
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