mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-26 21:03:31 +01:00
some more work. crashes serializing dbcommand
This commit is contained in:
parent
dedcd7a0f5
commit
004962866c
@ -117,8 +117,8 @@ public:
|
||||
bool shared() const { return m_shared; }
|
||||
|
||||
const QList< plentry_ptr >& entries() { return m_entries; }
|
||||
void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||
void addEntries( const QList<Tomahawk::query_ptr>& queries, const QString& oldrev );
|
||||
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||
virtual void addEntries( const QList<Tomahawk::query_ptr>& queries, const QString& oldrev );
|
||||
|
||||
// <IGNORE hack="true">
|
||||
// these need to exist and be public for the json serialization stuff
|
||||
@ -181,6 +181,8 @@ protected:
|
||||
const QList<QString>& oldorderedguids,
|
||||
bool is_newest_rev,
|
||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap );
|
||||
|
||||
QList<plentry_ptr> addEntriesInternal( const QList<Tomahawk::query_ptr>& queries );
|
||||
private:
|
||||
Playlist();
|
||||
|
||||
|
@ -161,9 +161,13 @@ DatabaseWorker::logOp( DatabaseCommandLoggable* command )
|
||||
"VALUES(?, ?, ?, ?, ?) ");
|
||||
|
||||
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant( command );
|
||||
qDebug() << "trying to serialize:" << variant.keys();
|
||||
foreach( const QString& key, variant.keys() ) {
|
||||
qDebug() << key << ":" << variant.value( key );
|
||||
}
|
||||
QByteArray ba = m_serializer.serialize( variant );
|
||||
|
||||
//qDebug() << "OP JSON:" << ba; // debug
|
||||
// qDebug() << "OP JSON:" << ba.isNull() << ba << "from:" << variant; // debug
|
||||
|
||||
bool compressed = false;
|
||||
if( ba.length() >= 512 )
|
||||
|
@ -65,9 +65,9 @@ public:
|
||||
virtual QWidget* inputField() { Q_ASSERT( false ); return 0; }
|
||||
|
||||
/// the serializable value of the match
|
||||
QString match() const { Q_ASSERT( false ); return QString(); }
|
||||
QString match() const { return m_match; }
|
||||
/// the serializable value of the input
|
||||
QString input() const { Q_ASSERT( false ); return QString(); }
|
||||
QString input() const { return m_input; }
|
||||
|
||||
// used by JSON serialization
|
||||
void setMatch( const QString& match ) { m_match = match; }
|
||||
|
@ -246,6 +246,25 @@ DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self )
|
||||
author()->collection()->deleteDynamicPlaylist( self );
|
||||
}
|
||||
|
||||
void DynamicPlaylist::addEntries(const QList< query_ptr >& queries, const QString& oldrev)
|
||||
{
|
||||
Q_ASSERT( m_generator->mode() == Static );
|
||||
|
||||
QList<plentry_ptr> el = addEntriesInternal( queries );
|
||||
|
||||
QString newrev = uuid();
|
||||
createNewRevision( newrev, oldrev, m_generator->type(), m_generator->controls(), el );
|
||||
}
|
||||
|
||||
void DynamicPlaylist::addEntry(const Tomahawk::query_ptr& query, const QString& oldrev)
|
||||
{
|
||||
QList<query_ptr> queries;
|
||||
queries << query;
|
||||
|
||||
addEntries( queries, oldrev );
|
||||
}
|
||||
|
||||
|
||||
// static version
|
||||
void
|
||||
DynamicPlaylist::setRevision( const QString& rev,
|
||||
|
@ -85,6 +85,9 @@ public:
|
||||
QString type() const;
|
||||
geninterface_ptr generator() const;
|
||||
|
||||
virtual void addEntries( const QList< query_ptr >& queries, const QString& oldrev );
|
||||
virtual void addEntry( const Tomahawk::query_ptr& query, const QString& oldrev );
|
||||
|
||||
// <IGNORE hack="true">
|
||||
// these need to exist and be public for the json serialization stuff
|
||||
// you SHOULD NOT call them. They are used for an alternate CTOR method from json.
|
||||
|
@ -379,29 +379,37 @@ void
|
||||
Playlist::addEntries( const QList<query_ptr>& queries, const QString& oldrev )
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QList<plentry_ptr> el = addEntriesInternal( queries );
|
||||
|
||||
QString newrev = uuid();
|
||||
createNewRevision( newrev, oldrev, el );
|
||||
}
|
||||
|
||||
QList<plentry_ptr>
|
||||
Playlist::addEntriesInternal( const QList<Tomahawk::query_ptr>& queries )
|
||||
{
|
||||
QList<plentry_ptr> el = entries();
|
||||
foreach( const query_ptr& query, queries )
|
||||
{
|
||||
plentry_ptr e( new PlaylistEntry() );
|
||||
e->setGuid( uuid() );
|
||||
|
||||
|
||||
if ( query->results().count() )
|
||||
e->setDuration( query->results().at( 0 )->duration() );
|
||||
else
|
||||
e->setDuration( 0 );
|
||||
|
||||
|
||||
e->setLastmodified( 0 );
|
||||
e->setAnnotation( "" ); // FIXME
|
||||
e->setQuery( query );
|
||||
|
||||
|
||||
el << e;
|
||||
}
|
||||
|
||||
QString newrev = uuid();
|
||||
createNewRevision( newrev, oldrev, el );
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
QList< plentry_ptr >
|
||||
Playlist::newEntries( const QList< plentry_ptr >& entries )
|
||||
{
|
||||
|
@ -282,7 +282,8 @@ TomahawkApp::registerMetaTypes()
|
||||
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
||||
qRegisterMetaType< QMap< QString, plentry_ptr > >("QMap< QString, plentry_ptr >");
|
||||
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
||||
|
||||
|
||||
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
||||
// Extra definition for namespaced-versions of signals/slots required
|
||||
qRegisterMetaType< Tomahawk::collection_ptr >("Tomahawk::collection_ptr");
|
||||
qRegisterMetaType< Tomahawk::result_ptr >("Tomahawk::result_ptr");
|
||||
|
Loading…
x
Reference in New Issue
Block a user