mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:17:28 +02:00
Fix indentation in BatchLoader
This commit is contained in:
parent
10e6157ab9
commit
946f3782f3
2 changed files with 17 additions and 17 deletions
|
@ -50,18 +50,18 @@ void BatchLoader::start() {
|
||||||
|
|
||||||
qCDebug(scriptengine) << "Loading script at " << url;
|
qCDebug(scriptengine) << "Loading script at " << url;
|
||||||
|
|
||||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||||
|
|
||||||
// Use a proxy callback to handle the call and emit the signal in a thread-safe way.
|
// Use a proxy callback to handle the call and emit the signal in a thread-safe way.
|
||||||
// If BatchLoader is deleted before the callback is called, the subsequent "emit" call will not do
|
// If BatchLoader is deleted before the callback is called, the subsequent "emit" call will not do
|
||||||
// anything.
|
// anything.
|
||||||
ScriptCacheSignalProxy* proxy = new ScriptCacheSignalProxy(scriptCache.data());
|
ScriptCacheSignalProxy* proxy = new ScriptCacheSignalProxy(scriptCache.data());
|
||||||
scriptCache->getScriptContents(url.toString(), [proxy](const QString& url, const QString& contents, bool isURL, bool success) {
|
scriptCache->getScriptContents(url.toString(), [proxy](const QString& url, const QString& contents, bool isURL, bool success) {
|
||||||
proxy->receivedContent(url, contents, isURL, success);
|
proxy->receivedContent(url, contents, isURL, success);
|
||||||
proxy->deleteLater();
|
proxy->deleteLater();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
connect(proxy, &ScriptCacheSignalProxy::contentAvailable, this, [this](const QString& url, const QString& contents, bool isURL, bool success) {
|
connect(proxy, &ScriptCacheSignalProxy::contentAvailable, this, [this](const QString& url, const QString& contents, bool isURL, bool success) {
|
||||||
if (isURL && success) {
|
if (isURL && success) {
|
||||||
_data.insert(url, contents);
|
_data.insert(url, contents);
|
||||||
qCDebug(scriptengine) << "Loaded: " << url;
|
qCDebug(scriptengine) << "Loaded: " << url;
|
||||||
|
@ -74,10 +74,10 @@ void BatchLoader::start() {
|
||||||
_finished = true;
|
_finished = true;
|
||||||
emit finished(_data);
|
emit finished(_data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptCacheSignalProxy::receivedContent(const QString& url, const QString& contents, bool isURL, bool success) {
|
void ScriptCacheSignalProxy::receivedContent(const QString& url, const QString& contents, bool isURL, bool success) {
|
||||||
emit contentAvailable(url, contents, isURL, success);
|
emit contentAvailable(url, contents, isURL, success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,19 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
class ScriptCacheSignalProxy : public QObject {
|
class ScriptCacheSignalProxy : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ScriptCacheSignalProxy(QObject* parent) : QObject(parent) { }
|
ScriptCacheSignalProxy(QObject* parent) : QObject(parent) { }
|
||||||
void receivedContent(const QString& url, const QString& contents, bool isURL, bool success);
|
void receivedContent(const QString& url, const QString& contents, bool isURL, bool success);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void contentAvailable(const QString& url, const QString& contents, bool isURL, bool success);
|
void contentAvailable(const QString& url, const QString& contents, bool isURL, bool success);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BatchLoader : public QObject {
|
class BatchLoader : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
BatchLoader(const QList<QUrl>& urls) ;
|
BatchLoader(const QList<QUrl>& urls);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
bool isFinished() const { return _finished; };
|
bool isFinished() const { return _finished; };
|
||||||
|
|
Loading…
Reference in a new issue