vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Thu Aug 18 23:34:36 2011 +0300| [6327c52db7c009adf77c4902bc04c342a73b0426] | committer: Rémi Denis-Courmont
Qt4: apply verbosity filtering within Qt, do not rely on core > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6327c52db7c009adf77c4902bc04c342a73b0426 --- include/vlc_messages.h | 33 ++++++++++++++++----------------- modules/gui/qt4/dialogs/messages.cpp | 22 +++++++++++++--------- modules/gui/qt4/dialogs/messages.hpp | 3 +++ 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/vlc_messages.h b/include/vlc_messages.h index a8782ab..ae3ac50 100644 --- a/include/vlc_messages.h +++ b/include/vlc_messages.h @@ -42,29 +42,28 @@ * @{ */ +/** Message types */ +enum msg_item_type +{ + VLC_MSG_INFO=0, /**< Important information */ + VLC_MSG_ERR, /**< Error */ + VLC_MSG_WARN, /**< Warning */ + VLC_MSG_DBG, /**< Debug */ +}; + /** - * Store a single message sent to user. + * Log message */ typedef struct { - int i_type; /**< message type, see below */ - uintptr_t i_object_id; - const char *psz_object_type; - const char *psz_module; - const char *psz_header; /**< Additional header */ - char * psz_msg; /**< the message itself */ + unsigned i_type; /**< Message type, see @ref msg_item_type */ + uintptr_t i_object_id; /**< Emitter (temporaly) unique object ID or 0 */ + const char *psz_object_type; /**< Emitter object type name */ + const char *psz_module; /**< Emitter module (source code) */ + const char *psz_header; /**< Additional header (used by VLM media) */ + char *psz_msg; /**< Message text */ } msg_item_t; -/* Message types */ -/** standard messages */ -#define VLC_MSG_INFO 0 -/** error messages */ -#define VLC_MSG_ERR 1 -/** warning messages */ -#define VLC_MSG_WARN 2 -/** debug messages */ -#define VLC_MSG_DBG 3 - VLC_MALLOC VLC_USED static inline msg_item_t *msg_Copy (const msg_item_t *msg) { diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp index 5c356be..a64594e 100644 --- a/modules/gui/qt4/dialogs/messages.cpp +++ b/modules/gui/qt4/dialogs/messages.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * Messages.cpp : Information about an item **************************************************************************** - * Copyright (C) 2006-2007 the VideoLAN team + * Copyright (C) 2006-2011 the VideoLAN team * $Id$ * * Authors: Jean-Baptiste Kempf <jb (at) videolan.org> @@ -25,6 +25,7 @@ #endif #include "dialogs/messages.hpp" +#include <vlc_atomic.h> #include <QTextEdit> #include <QTextCursor> @@ -73,8 +74,6 @@ struct msg_cb_data_t MessagesDialog *self; }; -static void MsgCallback( msg_cb_data_t *, const msg_item_t * ); - MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf ) { @@ -92,7 +91,9 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) /* Buttons and general layout */ ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) ); - ui.verbosityBox->setValue( var_InheritInteger( p_intf, "verbose" ) ); + int verbosity = var_InheritInteger( p_intf, "verbose" ); + vlc_atomic_set( &this->verbosity, verbosity ); + ui.verbosityBox->setValue( verbosity ); ui.vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects")); ui.vbobjectsEdit->setToolTip( "verbose-objects usage: \n" @@ -122,7 +123,6 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) cbData = new msg_cb_data_t; cbData->self = this; sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData ); - changeVerbosity( ui.verbosityBox->value() ); } MessagesDialog::~MessagesDialog() @@ -134,7 +134,7 @@ MessagesDialog::~MessagesDialog() void MessagesDialog::changeVerbosity( int verbosity ) { - msg_SubscriptionSetVerbosity( sub , verbosity ); + vlc_atomic_set( &this->verbosity, verbosity ); } void MessagesDialog::updateConfig() @@ -296,11 +296,15 @@ void MessagesDialog::tabChanged( int i ) updateButton->setVisible( i == 1 ); } -static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item ) +void MessagesDialog::MsgCallback( msg_cb_data_t *data, const msg_item_t *item ) { - int canc = vlc_savecancel(); + MessagesDialog *dialog = data->self; + int verbosity = vlc_atomic_get( &dialog->verbosity ); - QApplication::postEvent( data->self, new MsgEvent( item ) ); + if( verbosity < 0 || verbosity < (item->i_type - VLC_MSG_ERR) ) + return; + int canc = vlc_savecancel(); + QApplication::postEvent( dialog, new MsgEvent( item ) ); vlc_restorecancel( canc ); } diff --git a/modules/gui/qt4/dialogs/messages.hpp b/modules/gui/qt4/dialogs/messages.hpp index 3b9f66c..bc360ab 100644 --- a/modules/gui/qt4/dialogs/messages.hpp +++ b/modules/gui/qt4/dialogs/messages.hpp @@ -53,6 +53,9 @@ private: void customEvent( QEvent * ); void sinkMessage( MsgEvent * ); + vlc_atomic_t verbosity; + static void MsgCallback( msg_cb_data_t *, const msg_item_t * ); + private slots: bool save(); void updateConfig(); _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
