mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
fix crash which has been caused by the fact that we've called concurrent
data update and don't copy object (#66) * more correct concurrent run * move data split to awdataengineaggregator
This commit is contained in:
parent
6f86e8ec5e
commit
827275da3f
@ -8,7 +8,7 @@ ProjectRootRelative=./
|
|||||||
|
|
||||||
[CMake][CMake Build Directory 0]
|
[CMake][CMake Build Directory 0]
|
||||||
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||||
Build Type=Release
|
Build Type=Optimizaton
|
||||||
CMake Binary=file:///usr/bin/cmake
|
CMake Binary=file:///usr/bin/cmake
|
||||||
Environment Profile=
|
Environment Profile=
|
||||||
Extra Arguments=
|
Extra Arguments=
|
||||||
|
@ -67,8 +67,8 @@ void AWDataEngineAggregator::connectVisualization()
|
|||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
// reconnectSources();
|
// reconnectSources();
|
||||||
connect(this, SIGNAL(updateData(QString, QVariantMap)),
|
connect(this, SIGNAL(updateData(QString, QVariant, QString )),
|
||||||
parent(), SLOT(dataUpdated(QString, QVariantMap)));
|
parent(), SLOT(dataUpdated(QString, QVariant, QString)));
|
||||||
|
|
||||||
return static_cast<AWKeys *>(parent())->unlock();
|
return static_cast<AWKeys *>(parent())->unlock();
|
||||||
}
|
}
|
||||||
@ -78,8 +78,8 @@ void AWDataEngineAggregator::disconnectVisualization()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
disconnect(this, SIGNAL(updateData(QString, QVariantMap)),
|
disconnect(this, SIGNAL(updateData(QString, QVariant, QString)),
|
||||||
parent(), SLOT(dataUpdated(QString, QVariantMap)));
|
parent(), SLOT(dataUpdated(QString, QVariant, QString)));
|
||||||
// m_dataEngines.clear();
|
// m_dataEngines.clear();
|
||||||
|
|
||||||
// HACK run timer in the main thread since a timer could not be started from
|
// HACK run timer in the main thread since a timer could not be started from
|
||||||
@ -94,7 +94,7 @@ void AWDataEngineAggregator::dropSource(const QString source)
|
|||||||
qCDebug(LOG_AW) << "Source" << source;
|
qCDebug(LOG_AW) << "Source" << source;
|
||||||
|
|
||||||
// FIXME there is no possiblibity to check to which dataengine source connected
|
// FIXME there is no possiblibity to check to which dataengine source connected
|
||||||
// we will try to disconnet it from systemmonitor and extsysmon
|
// we will try to disconnect it from systemmonitor and extsysmon
|
||||||
m_dataEngines[QString("systemmonitor")]->disconnectSource(source, this);
|
m_dataEngines[QString("systemmonitor")]->disconnectSource(source, this);
|
||||||
m_dataEngines[QString("extsysmon")]->disconnectSource(source, this);
|
m_dataEngines[QString("extsysmon")]->disconnectSource(source, this);
|
||||||
}
|
}
|
||||||
@ -116,7 +116,12 @@ void AWDataEngineAggregator::dataUpdated(const QString sourceName, const Plasma:
|
|||||||
qCDebug(LOG_AW) << "Source" << sourceName;
|
qCDebug(LOG_AW) << "Source" << sourceName;
|
||||||
qCDebug(LOG_AW) << "Data" << data;
|
qCDebug(LOG_AW) << "Data" << data;
|
||||||
|
|
||||||
return emit(updateData(sourceName, data));
|
// HACK "deep copy" of data to avoid plasma crash on Data object destruction
|
||||||
|
QString units = data[QString("units")].toString();
|
||||||
|
// HACK workaround for time values which are stored in the different path
|
||||||
|
QVariant value = sourceName == QString("Local") ? data[QString("DateTime")] : data[QString("value")];
|
||||||
|
|
||||||
|
emit(updateData(sourceName, value, units));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startTimer();
|
void startTimer();
|
||||||
void updateData(const QString sourceName, const QVariantMap sdata);
|
void updateData(const QString sourceName, const QVariant value, const QString units);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// additional methods to control this and visualization
|
// additional methods to control this and visualization
|
||||||
|
@ -403,22 +403,20 @@ void AWKeys::addDevice(const QString source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::dataUpdated(const QString sourceName, const QVariantMap data)
|
void AWKeys::dataUpdated(const QString sourceName, const QVariant value, const QString units)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
qCDebug(LOG_AW) << "Source" << sourceName;
|
qCDebug(LOG_AW) << "Source" << sourceName;
|
||||||
qCDebug(LOG_AW) << "Data" << data;
|
qCDebug(LOG_AW) << "Data" << value << units;
|
||||||
|
|
||||||
if (lock) return;
|
if (lock) return;
|
||||||
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
||||||
|
|
||||||
#ifdef BUILD_FUTURE
|
#ifdef BUILD_FUTURE
|
||||||
// run concurrent data update
|
// run concurrent data update
|
||||||
QtConcurrent::run(threadPool, [this, sourceName, data]() {
|
QtConcurrent::run(threadPool, this, &AWKeys::setDataBySource, sourceName, value, units);
|
||||||
return setDataBySource(sourceName, data);
|
|
||||||
});
|
|
||||||
#else /* BUILD_FUTURE */
|
#else /* BUILD_FUTURE */
|
||||||
return setDataBySource(sourceName, data);
|
return setDataBySource(sourceName, value, units);
|
||||||
#endif /* BUILD_FUTURE */
|
#endif /* BUILD_FUTURE */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,11 +696,11 @@ QString AWKeys::parsePattern(QString pattern) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data)
|
void AWKeys::setDataBySource(const QString sourceName, const QVariant value, const QString units)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
qCDebug(LOG_AW) << "Source" << sourceName;
|
qCDebug(LOG_AW) << "Source" << sourceName;
|
||||||
qCDebug(LOG_AW) << "Data" << data;
|
qCDebug(LOG_AW) << "Data" << value << units;
|
||||||
|
|
||||||
#ifdef BUILD_FUTURE
|
#ifdef BUILD_FUTURE
|
||||||
// drop if limits are reached
|
// drop if limits are reached
|
||||||
@ -716,15 +714,13 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data)
|
|||||||
// first list init
|
// first list init
|
||||||
QStringList tags = aggregator->keysFromSource(sourceName);
|
QStringList tags = aggregator->keysFromSource(sourceName);
|
||||||
if (tags.isEmpty())
|
if (tags.isEmpty())
|
||||||
tags = aggregator->registerSource(sourceName, data[QString("units")].toString());
|
tags = aggregator->registerSource(sourceName, units);
|
||||||
|
|
||||||
// update data or drop source if there are no matches
|
// update data or drop source if there are no matches
|
||||||
if (tags.isEmpty()) {
|
if (tags.isEmpty()) {
|
||||||
qCDebug(LOG_AW) << "Source" << sourceName << "not found";
|
qCDebug(LOG_AW) << "Source" << sourceName << "not found";
|
||||||
emit(dropSourceFromDataengine(sourceName));
|
emit(dropSourceFromDataengine(sourceName));
|
||||||
} else {
|
} else {
|
||||||
// HACK workaround for time values which are stored in the different path
|
|
||||||
QVariant value = sourceName == QString("Local") ? data[QString("DateTime")] : data[QString("value")];
|
|
||||||
std::for_each(tags.cbegin(), tags.cend(), [this, value](const QString tag) {
|
std::for_each(tags.cbegin(), tags.cend(), [this, value](const QString tag) {
|
||||||
values[tag] = aggregator->formater(value, tag);
|
values[tag] = aggregator->formater(value, tag);
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addDevice(const QString source);
|
void addDevice(const QString source);
|
||||||
void dataUpdated(const QString sourceName, const QVariantMap data);
|
void dataUpdated(const QString sourceName, const QVariant value, const QString units);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropSourceFromDataengine(const QString source);
|
void dropSourceFromDataengine(const QString source);
|
||||||
@ -78,7 +78,7 @@ private:
|
|||||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||||
void calculateValues();
|
void calculateValues();
|
||||||
QString parsePattern(QString pattern) const;
|
QString parsePattern(QString pattern) const;
|
||||||
void setDataBySource(const QString sourceName, const QVariantMap data);
|
void setDataBySource(const QString sourceName, const QVariant value, const QString units);
|
||||||
// objects
|
// objects
|
||||||
AWDataAggregator *dataAggregator = nullptr;
|
AWDataAggregator *dataAggregator = nullptr;
|
||||||
AWDataEngineAggregator *dataEngineAggregator = nullptr;
|
AWDataEngineAggregator *dataEngineAggregator = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user