mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Give each playlist a weak pointer to its own shared pointer
This commit is contained in:
parent
111de47023
commit
70aa98753b
@ -189,6 +189,7 @@ Playlist::create( const source_ptr& author,
|
||||
}
|
||||
|
||||
playlist_ptr playlist( new Playlist( author, guid, title, info, creator, shared, entries ), &QObject::deleteLater );
|
||||
playlist->setWeakSelf( playlist.toWeakRef() );
|
||||
|
||||
// save to DB in the background
|
||||
// Watch for the created() signal if you need to be sure it's written.
|
||||
@ -710,6 +711,13 @@ Playlist::checkRevisionQueue()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Playlist::setWeakSelf( QWeakPointer< Playlist > self )
|
||||
{
|
||||
m_weakSelf = self;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Playlist::playlistInterface()
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
class SourceTreePopupDialog;
|
||||
class DatabaseCommand_LoadAllPlaylists;
|
||||
class DatabaseCommand_LoadAllSortedPlaylists;
|
||||
class DatabaseCommand_SetPlaylistRevision;
|
||||
@ -249,6 +250,7 @@ public slots:
|
||||
|
||||
void resolve();
|
||||
|
||||
void setWeakSelf( QWeakPointer< Playlist > self );
|
||||
protected:
|
||||
// called from loadAllPlaylists DB cmd:
|
||||
explicit Playlist( const source_ptr& src,
|
||||
@ -289,6 +291,7 @@ private:
|
||||
void setBusy( bool b );
|
||||
void checkRevisionQueue();
|
||||
|
||||
QWeakPointer< Playlist > m_weakSelf;
|
||||
source_ptr m_source;
|
||||
QString m_currentrevision;
|
||||
QString m_guid, m_title, m_info, m_creator;
|
||||
|
@ -144,6 +144,8 @@ DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVarian
|
||||
data[7].toBool(), //shared
|
||||
data[8].toInt(), //lastmod
|
||||
data[9].toString() ), &QObject::deleteLater ); //GUID
|
||||
p->setWeakSelf( p.toWeakRef() );
|
||||
|
||||
addAutoPlaylist( p );
|
||||
}
|
||||
|
||||
@ -162,6 +164,8 @@ DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList
|
||||
data[7].toBool(), //shared
|
||||
data[8].toInt(), //lastmod
|
||||
data[9].toString() ), &QObject::deleteLater ); //GUID
|
||||
p->setWeakSelf( p.toWeakRef() );
|
||||
|
||||
addStation( p );
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
||||
query.value(4).toInt(), //lastmod
|
||||
query.value(0).toString() //GUID
|
||||
), &QObject::deleteLater );
|
||||
p->setWeakSelf( p.toWeakRef() );
|
||||
plists.append( p );
|
||||
}
|
||||
|
||||
|
@ -70,38 +70,7 @@ DatabaseCommand_LoadAllSortedPlaylists::exec( DatabaseImpl* dbi )
|
||||
while ( query.next() )
|
||||
{
|
||||
plists << QPair< int, QString >( query.value(9).toInt(), query.value(0).toString() );
|
||||
// playlist_ptr p;
|
||||
// bool dynamic = query.value(8).toBool();
|
||||
// source_ptr s = SourceList::instance()->get( query.value(9).toInt() );
|
||||
//
|
||||
// if ( dynamic )
|
||||
// {
|
||||
// p = dynplaylist_ptr( new DynamicPlaylist( s,
|
||||
// query.value(6).toString(), //current rev
|
||||
// query.value(1).toString(), //title
|
||||
// query.value(2).toString(), //info
|
||||
// query.value(3).toString(), //creator
|
||||
// query.value(7).toInt(), //createdOn
|
||||
// query.value(10).toString(), //type
|
||||
// (GeneratorMode)query.value(11).toInt(), // mode
|
||||
// query.value(5).toBool(), //shared
|
||||
// query.value(4).toInt(), //lastmod
|
||||
// query.value(0).toString() //GUID
|
||||
// ) );
|
||||
// } else
|
||||
// {
|
||||
// p = playlist_ptr( new Playlist( s, //src
|
||||
// query.value(6).toString(), //current rev
|
||||
// query.value(1).toString(), //title
|
||||
// query.value(2).toString(), //info
|
||||
// query.value(3).toString(), //creator
|
||||
// query.value(7).toInt(), //createdOn
|
||||
// query.value(5).toBool(), //shared
|
||||
// query.value(4).toInt(), //lastmod
|
||||
// query.value(0).toString() //GUID
|
||||
// ) );
|
||||
// }
|
||||
// plists.append( p );
|
||||
|
||||
}
|
||||
|
||||
emit done( plists );
|
||||
|
@ -60,6 +60,8 @@ Tomahawk::DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi )
|
||||
query.value(5).toInt(), //lastmod
|
||||
query.value(0).toString() ) ); //GUID
|
||||
|
||||
p->setWeakSelf( p.toWeakRef() );
|
||||
/*
|
||||
tLog() << "Loaded individual dynamic playlist:" << query.value(7).toString() //current rev
|
||||
<< query.value(1).toString() //title
|
||||
<< query.value(2).toString() //info
|
||||
@ -69,7 +71,7 @@ Tomahawk::DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi )
|
||||
<< static_cast<GeneratorMode>(query.value(9).toInt()) // dynamic mode
|
||||
<< query.value(6).toBool() //shared
|
||||
<< query.value(5).toInt() //lastmod
|
||||
<< query.value(0).toString(); //GUID
|
||||
<< query.value(0).toString(); //GUID */
|
||||
|
||||
emit dynamicPlaylistLoaded( p );
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author,
|
||||
)
|
||||
{
|
||||
dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ), &QObject::deleteLater );
|
||||
dynplaylist->setWeakSelf( dynplaylist.toWeakRef() );
|
||||
|
||||
DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad );
|
||||
connect( cmd, SIGNAL(finished()), dynplaylist.data(), SIGNAL(created()) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user