Commit f70a9052 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: restore message dialog

(bug at exit due to more generic problems with #2226 and #2227)
parent 42b58e87
...@@ -39,9 +39,16 @@ ...@@ -39,9 +39,16 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QHeaderView> #include <QHeaderView>
#include <QMutex>
MessagesDialog *MessagesDialog::instance = NULL; MessagesDialog *MessagesDialog::instance = NULL;
struct msg_cb_data_t
{
MessagesDialog *self;
QMutex lock; /**< protects MessagesDialog::messages */
};
MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
: QVLCFrame( _p_intf ) : QVLCFrame( _p_intf )
{ {
...@@ -64,7 +71,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -64,7 +71,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
msgLayout->addWidget( messages, 0, 0, 1, 0 ); msgLayout->addWidget( messages, 0, 0, 1, 0 );
mainTab->addTab( msgWidget, qtr( "Messages" ) ); mainTab->addTab( msgWidget, qtr( "Messages" ) );
// ON_TIMEOUT( updateLog() );
/* Modules tree */ /* Modules tree */
...@@ -109,8 +115,21 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -109,8 +115,21 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
/* General action */ /* General action */
readSettings( "Messages", QSize( 600, 450 ) ); readSettings( "Messages", QSize( 600, 450 ) );
/* Hook up to LibVLC messaging */
cb_data = new msg_cb_data_t;
cb_data->self = this;
sub = msg_Subscribe (_p_intf->p_libvlc, sinkMessage, cb_data);
} }
MessagesDialog::~MessagesDialog ()
{
writeSettings( "messages" );
msg_Unsubscribe (sub);
delete cb_data;
};
void MessagesDialog::updateTab( int index ) void MessagesDialog::updateTab( int index )
{ {
/* Second tab : modules tree */ /* Second tab : modules tree */
...@@ -132,39 +151,27 @@ void MessagesDialog::updateTab( int index ) ...@@ -132,39 +151,27 @@ void MessagesDialog::updateTab( int index )
} }
} }
void MessagesDialog::updateLog() void MessagesDialog::sinkMessage (msg_cb_data_t *data, msg_item_t *item,
unsigned overruns)
{ {
#if 0 MessagesDialog *self = data->self;
msg_subscription_t *p_sub = p_intf->p_sys->p_sub; QMutexLocker locker (&data->lock);
int i_start;
vlc_mutex_lock( p_sub->p_lock ); self->sinkMessage (item, overruns);
int i_stop = *p_sub->pi_stop; }
vlc_mutex_unlock( p_sub->p_lock );
if( p_sub->i_start != i_stop ) void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
{ {
messages->textCursor().movePosition( QTextCursor::End ); if ((item->i_type == VLC_MSG_WARN && verbosityBox->value() < 1)
|| (item->i_type == VLC_MSG_DBG && verbosityBox->value() < 2 ))
return;
for( i_start = p_sub->i_start; messages->textCursor().movePosition( QTextCursor::End );
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
if( p_sub->p_msg[i_start].i_type == VLC_MSG_INFO ||
p_sub->p_msg[i_start].i_type == VLC_MSG_ERR ||
p_sub->p_msg[i_start].i_type == VLC_MSG_WARN &&
verbosityBox->value() >= 1 ||
p_sub->p_msg[i_start].i_type == VLC_MSG_DBG &&
verbosityBox->value() >= 2 )
{
messages->setFontItalic( true ); messages->setFontItalic( true );
messages->setTextColor( "darkBlue" ); messages->setTextColor( "darkBlue" );
messages->insertPlainText( qfu( p_sub->p_msg[i_start].psz_module ) ); messages->insertPlainText( qfu( item->psz_module ) );
}
else
continue;
switch( p_sub->p_msg[i_start].i_type ) switch (item->i_type)
{ {
case VLC_MSG_INFO: case VLC_MSG_INFO:
messages->setTextColor( "blue" ); messages->setTextColor( "blue" );
...@@ -188,16 +195,9 @@ void MessagesDialog::updateLog() ...@@ -188,16 +195,9 @@ void MessagesDialog::updateLog()
/* Add message Regular black Font */ /* Add message Regular black Font */
messages->setFontItalic( false ); messages->setFontItalic( false );
messages->setTextColor( "black" ); messages->setTextColor( "black" );
messages->insertPlainText( qfu(p_sub->p_msg[i_start].psz_msg) ); messages->insertPlainText( qfu(item->psz_msg) );
messages->insertPlainText( "\n" ); messages->insertPlainText( "\n" );
}
messages->ensureCursorVisible(); messages->ensureCursorVisible();
vlc_mutex_lock( p_sub->p_lock );
p_sub->i_start = i_start;
vlc_mutex_unlock( p_sub->p_lock );
}
#endif
} }
void MessagesDialog::buildTree( QTreeWidgetItem *parentItem, void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
...@@ -242,6 +242,7 @@ void MessagesDialog::updateTree() ...@@ -242,6 +242,7 @@ void MessagesDialog::updateTree()
void MessagesDialog::clear() void MessagesDialog::clear()
{ {
QMutexLocker locker (&cb_data->lock);
messages->clear(); messages->clear();
} }
...@@ -264,6 +265,7 @@ bool MessagesDialog::save() ...@@ -264,6 +265,7 @@ bool MessagesDialog::save()
} }
QTextStream out( &file ); QTextStream out( &file );
QMutexLocker locker (&cb_data->lock);
out << messages->toPlainText() << "\n"; out << messages->toPlainText() << "\n";
return true; return true;
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
instance = NULL; instance = NULL;
} }
virtual ~MessagesDialog(){ writeSettings( "messages" ); }; virtual ~MessagesDialog();
private: private:
MessagesDialog( intf_thread_t * ); MessagesDialog( intf_thread_t * );
...@@ -63,10 +63,13 @@ private: ...@@ -63,10 +63,13 @@ private:
QTreeWidget *modulesTree; QTreeWidget *modulesTree;
QPushButton *clearUpdateButton; QPushButton *clearUpdateButton;
QPushButton *saveLogButton; QPushButton *saveLogButton;
msg_subscription_t *sub;
msg_cb_data_t *cb_data;
static void sinkMessage (msg_cb_data_t *, msg_item_t *, unsigned);
void sinkMessage (msg_item_t *item, unsigned);
private slots: private slots:
void updateTab( int ); void updateTab( int );
void updateLog();
void clearOrUpdate(); void clearOrUpdate();
bool save(); bool save();
private: private:
......
...@@ -263,8 +263,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -263,8 +263,6 @@ static int Open( vlc_object_t *p_this )
/* Access to the playlist */ /* Access to the playlist */
p_intf->p_sys->p_playlist = pl_Hold( p_intf ); p_intf->p_sys->p_playlist = pl_Hold( p_intf );
/* Listen to the messages */
//p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, NULL, NULL );
/* one settings to rule them all */ /* one settings to rule them all */
var_Create( p_this, "window_widget", VLC_VAR_ADDRESS ); var_Create( p_this, "window_widget", VLC_VAR_ADDRESS );
...@@ -298,7 +296,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -298,7 +296,6 @@ static void Close( vlc_object_t *p_this )
} }
vlc_object_release( p_intf->p_sys->p_playlist ); vlc_object_release( p_intf->p_sys->p_playlist );
//msg_Unsubscribe( p_intf->p_sys->p_sub );
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
......
...@@ -72,7 +72,6 @@ struct intf_sys_t ...@@ -72,7 +72,6 @@ struct intf_sys_t
bool b_isDialogProvider; bool b_isDialogProvider;
playlist_t *p_playlist; playlist_t *p_playlist;
msg_subscription_t *p_sub; ///< Subscription to the message bank
VideoWidget *p_video; VideoWidget *p_video;
......
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