mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
Possible one more performance increasing
Lets try to use own QueuedConnection type instead of default AutoConnection. To implement it we need to disconnect all default slots and reconnect them with specified connection type
This commit is contained in:
parent
8f6d9e7ab5
commit
a9e3e3f087
@ -17,6 +17,8 @@
|
||||
|
||||
#include "awdataengineaggregator.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
#include "awdebug.h"
|
||||
#include "awkeys.h"
|
||||
|
||||
@ -25,6 +27,9 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
// required to define Qt::QueuedConnection for signal-slot connection
|
||||
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
||||
}
|
||||
|
||||
|
||||
@ -98,4 +103,33 @@ void AWDataEngineAggregator::reconnectSources(const int interval)
|
||||
m_dataEngines[QString("extsysmon")]->connectAllSources(parent(), interval);
|
||||
m_dataEngines[QString("time")]->connectSource(QString("Local"), parent(),
|
||||
1000);
|
||||
|
||||
#ifdef BUILD_FUTURE
|
||||
createQueuedConnection();
|
||||
#endif /* BUILD_FUTURE */
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::createQueuedConnection()
|
||||
{
|
||||
// HACK additional method which forces QueuedConnection instead of Auto one
|
||||
// for more details refer to plasma-framework source code
|
||||
for (auto dataEngine : m_dataEngines.keys()) {
|
||||
// different source set for different engines
|
||||
QStringList sources;
|
||||
if (dataEngine == QString("time"))
|
||||
sources.append(QString("Local"));
|
||||
else
|
||||
sources = m_dataEngines[dataEngine]->sources();
|
||||
// reconnect sources
|
||||
for (auto source : sources) {
|
||||
Plasma::DataContainer *container =m_dataEngines[dataEngine]->containerForSource(source);
|
||||
// disconnect old connections first
|
||||
disconnect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
||||
parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
||||
// and now reconnect with Qt::QueuedConnection type
|
||||
connect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
||||
parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data)), Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public slots:
|
||||
void reconnectSources(const int interval);
|
||||
|
||||
private:
|
||||
void createQueuedConnection();
|
||||
Plasma::DataEngineConsumer *m_consumer = nullptr;
|
||||
QHash<QString, Plasma::DataEngine *> m_dataEngines;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user