Commit bb964cd5 authored by Erwan Tulou's avatar Erwan Tulou

Qt: fix playlist issues when Qt works as a dialog provider

For the Qt plugin to keep on working both as an interface module and
a dialog/menu/extension provider, the new implementation of pl_Get( p_intf )
can no longer be used blindly, since it now assumes that the playlist is the
parent object. In the latter case, the parent object is the calling interface
(for instance, skins2) and the playlist is actually the grandparent !

As a rule of thumb, THEPL which is now initialized appropriately should be
used instead of pl_Get( p_intf ) throughout Qt.

This fixes trac #10421
parent 9bf135cb
......@@ -190,7 +190,7 @@ void SoundWidget::showVolumeMenu( QPoint pos )
void SoundWidget::setMuted( bool mute )
{
b_is_muted = mute;
playlist_t *p_playlist = pl_Get( p_intf );
playlist_t *p_playlist = THEPL;
playlist_MuteSet( p_playlist, mute );
}
......
......@@ -398,7 +398,7 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_
/* Try to set on the fly */
if( !strcmp( psz_filter_type, "video-splitter" ) )
{
playlist_t *p_playlist = pl_Get( p_intf );
playlist_t *p_playlist = THEPL;
var_SetString( p_playlist, psz_filter_type, psz_string );
}
else
......@@ -714,7 +714,7 @@ void ExtV4l2::showEvent( QShowEvent *event )
void ExtV4l2::Refresh( void )
{
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( THEPL, "v4l2" );
help->hide();
if( box )
{
......@@ -877,7 +877,7 @@ void ExtV4l2::ValueChange( bool value )
void ExtV4l2::ValueChange( int value )
{
QObject *s = sender();
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( THEPL, "v4l2" );
if( p_obj )
{
QString var = s->objectName();
......
......@@ -307,8 +307,7 @@ void MetaPanel::saveMeta()
input_item_SetPublisher( p_input, qtu( publisher_text->text() ) );
input_item_SetDescription( p_input, qtu( description_text->toPlainText() ) );
playlist_t *p_playlist = pl_Get( p_intf );
input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
input_item_WriteMeta( VLC_OBJECT(THEPL), p_input );
/* Reset the status of the mode. No need to emit any signal because parent
is the only caller */
......
......@@ -459,7 +459,7 @@ static void AddItemToPlaylist( int i_media_id, bool bPlay, media_library_t* p_ml
i_media_id );
return;
}
playlist_t *p_playlist = pl_Get( p_ml );
playlist_t *p_playlist = THEPL;
playlist_item_t *p_playlist_item = NULL;
playlist_Lock( p_playlist );
......
......@@ -965,7 +965,7 @@ void PLModel::renameNode( QModelIndex index, QString name )
if ( !index.isValid() ) index = rootIndex();
input_item_t* p_input = this->getInputItem( index );
input_item_SetName( p_input, qtu( name ) );
playlist_t *p_playlist = pl_Get( p_intf );
playlist_t *p_playlist = THEPL;
input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
PL_UNLOCK;
}
......
......@@ -987,7 +987,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
im, setInput( input_thread_t * ) );
/* initialize p_input (an input can already be running) */
p_input = playlist_CurrentInput( pl_Get(p_intf) );
p_input = playlist_CurrentInput( THEPL );
if( p_input )
emit inputChanged( p_input );
......@@ -1055,7 +1055,7 @@ void MainInputManager::customEvent( QEvent *event )
if( p_input != NULL )
vlc_object_release( p_input );
p_input = playlist_CurrentInput( pl_Get(p_intf) );
p_input = playlist_CurrentInput( THEPL );
emit inputChanged( p_input );
}
......
......@@ -334,7 +334,7 @@ static void Abort( void *obj )
static void RegisterIntf( intf_thread_t *p_this )
{
playlist_t *pl = pl_Get(p_this);
playlist_t *pl = p_this->p_sys->p_playlist;
var_Create (pl, "qt4-iface", VLC_VAR_ADDRESS);
var_SetAddress (pl, "qt4-iface", p_this);
var_Create (pl, "window", VLC_VAR_STRING);
......@@ -372,6 +372,12 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
p_sys->p_mi = NULL;
p_sys->pl_model = NULL;
/* set up the playlist to work on */
if( isDialogProvider )
p_intf->p_sys->p_playlist = pl_Get( (intf_thread_t *)p_intf->p_parent );
else
p_intf->p_sys->p_playlist = pl_Get( p_intf );
/* */
vlc_sem_init (&ready, 0);
#ifdef Q_OS_MAC
......@@ -420,7 +426,7 @@ static void Close( vlc_object_t *p_this )
if( !p_sys->b_isDialogProvider )
{
playlist_t *pl = pl_Get(p_intf);
playlist_t *pl = THEPL;
var_Destroy (pl, "window");
var_Destroy (pl, "qt4-iface");
......
......@@ -78,12 +78,13 @@ struct intf_sys_t
int i_screenHeight; /* Detection of Small screens */
unsigned voutWindowType; /* Type of vout_window_t provided */
bool b_isDialogProvider; /* Qt mode or Skins mode */
playlist_t *p_playlist; /* playlist */
#ifdef _WIN32
bool disable_volume_keys;
#endif
};
#define THEPL pl_Get(p_intf)
#define THEPL p_intf->p_sys->p_playlist
#define QPL_LOCK playlist_Lock( THEPL );
#define QPL_UNLOCK playlist_Unlock( THEPL );
......
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