1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-19 23:41:51 +02:00

* DynamicPlaylist needs to store its own weak-ptr so we can access the dynplaylist_ptr (instead of only the playlist_ptr) internally.

This commit is contained in:
Christian Muehlhaeuser 2013-09-06 11:09:38 +02:00
parent 2244f23fde
commit 945942b18a
3 changed files with 17 additions and 4 deletions

View File

@ -50,7 +50,6 @@ DynamicPlaylist::DynamicPlaylist( const Tomahawk::source_ptr& author, const QStr
DynamicPlaylist::~DynamicPlaylist()
{
}
@ -172,10 +171,19 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author,
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
if ( autoLoad )
dynplaylist->reportCreated( dynplaylist );
return dynplaylist;
}
void
DynamicPlaylist::setWeakSelf( QWeakPointer< DynamicPlaylist > self )
{
Q_D( DynamicPlaylist );
d->weakSelf = self;
}
void
DynamicPlaylist::createNewRevision( const QString& newUuid )
{
@ -505,8 +513,11 @@ DynamicPlaylist::setRevision( const QString& rev,
void
DynamicPlaylist::removeFromDatabase()
{
Q_D( DynamicPlaylist );
emit aboutToBeDeleted( d->weakSelf.toStrongRef() );
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeleteDynamicPlaylist( author(), guid() ) ;
Database::instance()->enqueue( Tomahawk::dbcmd_ptr(cmd) );
Database::instance()->enqueue( Tomahawk::dbcmd_ptr( cmd ) );
}

View File

@ -32,8 +32,6 @@
#include <QList>
#include <QSharedPointer>
namespace Tomahawk
{
@ -156,6 +154,8 @@ public slots:
const QList< Tomahawk::dyncontrol_ptr>& controls,
bool applied );
void setWeakSelf( QWeakPointer< DynamicPlaylist > self );
protected:
virtual void removeFromDatabase();

View File

@ -72,6 +72,8 @@ public:
Q_DECLARE_PUBLIC( DynamicPlaylist )
private:
QWeakPointer< DynamicPlaylist > weakSelf;
geninterface_ptr generator;
bool autoLoad;