mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Fix a bug and start the skeleton for the thread-based worker
This commit is contained in:
@@ -35,28 +35,6 @@ InfoPlugin::InfoPlugin(QObject *parent)
|
|||||||
:QObject( parent )
|
:QObject( parent )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
InfoSystem *system = qobject_cast< InfoSystem* >( parent );
|
|
||||||
if( system )
|
|
||||||
{
|
|
||||||
QObject::connect(
|
|
||||||
this,
|
|
||||||
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
|
||||||
system->getCache(),
|
|
||||||
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
|
||||||
);
|
|
||||||
QObject::connect(
|
|
||||||
system->getCache(),
|
|
||||||
SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
|
||||||
this,
|
|
||||||
SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
|
||||||
);
|
|
||||||
QObject::connect(
|
|
||||||
this,
|
|
||||||
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
|
||||||
system->getCache(),
|
|
||||||
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +46,7 @@ InfoSystem::instance()
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystem::InfoSystem(QObject *parent)
|
InfoSystem::InfoSystem(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -96,6 +75,25 @@ InfoSystem::InfoSystem(QObject *parent)
|
|||||||
SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||||
Qt::UniqueConnection
|
Qt::UniqueConnection
|
||||||
);
|
);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
plugin.data(),
|
||||||
|
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||||
|
m_cache,
|
||||||
|
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
||||||
|
);
|
||||||
|
connect(
|
||||||
|
m_cache,
|
||||||
|
SIGNAL( notInCache( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||||
|
plugin.data(),
|
||||||
|
SLOT( notInCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, QString, Tomahawk::InfoSystem::InfoType, QVariant, Tomahawk::InfoSystem::InfoCustomData ) )
|
||||||
|
);
|
||||||
|
connect(
|
||||||
|
plugin.data(),
|
||||||
|
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||||
|
m_cache,
|
||||||
|
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoCriteriaHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
connect( m_cache, SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
connect( m_cache, SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||||
this, SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ), Qt::UniqueConnection );
|
this, SLOT( infoSlot( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ), Qt::UniqueConnection );
|
||||||
@@ -154,7 +152,7 @@ void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVari
|
|||||||
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
|
QLinkedList< InfoPluginPtr > providers = determineOrderedMatches(type);
|
||||||
if (providers.isEmpty())
|
if (providers.isEmpty())
|
||||||
{
|
{
|
||||||
emit info(QString(), InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
emit finished(caller);
|
emit finished(caller);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,7 @@ void InfoSystem::getInfo(const QString &caller, const InfoType type, const QVari
|
|||||||
InfoPluginPtr ptr = providers.first();
|
InfoPluginPtr ptr = providers.first();
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
emit info(QString(), InfoNoInfo, QVariant(), QVariant(), customData);
|
emit info(caller, InfoNoInfo, QVariant(), QVariant(), customData);
|
||||||
emit finished(caller);
|
emit finished(caller);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -135,11 +135,17 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class InfoSystem;
|
friend class InfoSystem;
|
||||||
friend class InfoSystemCache;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QWeakPointer< InfoPlugin > InfoPluginPtr;
|
typedef QWeakPointer< InfoPlugin > InfoPluginPtr;
|
||||||
|
|
||||||
|
class DLLEXPORT InfoSystemWorker : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
InfoSystemWorker() {};
|
||||||
|
~InfoSystemWorker() {};
|
||||||
|
};
|
||||||
|
|
||||||
class DLLEXPORT InfoSystem : public QObject
|
class DLLEXPORT InfoSystem : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -175,7 +181,9 @@ private:
|
|||||||
QHash< QString, QHash< InfoType, int > > m_dataTracker;
|
QHash< QString, QHash< InfoType, int > > m_dataTracker;
|
||||||
|
|
||||||
InfoSystemCache* m_cache;
|
InfoSystemCache* m_cache;
|
||||||
|
InfoSystemWorker* m_worker;
|
||||||
QThread* m_infoSystemCacheThreadController;
|
QThread* m_infoSystemCacheThreadController;
|
||||||
|
QThread* m_infoSystemWorkerThreadController;
|
||||||
|
|
||||||
static InfoSystem* s_instance;
|
static InfoSystem* s_instance;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user