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