Skip to content

Commit

Permalink
QtLocationPlugin: Update TileCacheWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Sep 6, 2024
1 parent 08f3e87 commit 7881fd2
Show file tree
Hide file tree
Showing 7 changed files with 1,455 additions and 936 deletions.
4 changes: 3 additions & 1 deletion src/QtLocationPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ qt_add_plugin(QGCLocation STATIC
QGCMapUrlEngine.cpp
QGCMapUrlEngine.h
QGCTile.h
QGCTileCacheDatabase.cpp
QGCTileCacheDatabase.h
QGCTileCacheWorker.cpp
QGCTileCacheWorker.h
QGCTileSet.h
Expand Down Expand Up @@ -53,6 +55,7 @@ endif()
target_link_libraries(QGCLocation
PRIVATE
Qt6::Positioning
Qt6::Sql
QGC
Settings
Utilities
Expand All @@ -61,7 +64,6 @@ target_link_libraries(QGCLocation
Qt6::Location
Qt6::LocationPrivate
Qt6::Network
Qt6::Sql
QmlControls
)

Expand Down
28 changes: 18 additions & 10 deletions src/QtLocationPlugin/QGCMapEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <QtCore/qapplicationstatic.h>
#include <QtCore/QStandardPaths>
#include <QtCore/QDir>
#include <QtCore/QThread>
#include <qnamespace.h>

#define CACHE_PATH_VERSION "300"

Expand All @@ -51,23 +53,27 @@ QGCMapEngine* QGCMapEngine::instance()
QGCMapEngine::QGCMapEngine(QObject *parent)
: QObject(parent)
, m_worker(new QGCCacheWorker(this))
// , m_thread(new QThread(this))
{
// qCDebug(QGCMapEngineLog) << Q_FUNC_INFO << this;

(void) qRegisterMetaType<QGCMapTask::TaskType>();
(void) qRegisterMetaType<QGCTile>();
(void) qRegisterMetaType<QList<QGCTile*>>();
(void) qRegisterMetaType<QGCTileSet>();
(void) qRegisterMetaType<QGCCacheTile>();
(void) qRegisterMetaType<QGCMapTask::TaskType>("GCMapTask::TaskType");
(void) qRegisterMetaType<QGCTile>("QGCTile");
(void) qRegisterMetaType<QList<QGCTile*>>("QList<QGCTile*>");
(void) qRegisterMetaType<QGCTileSet>("QGCTileSet");
(void) qRegisterMetaType<QGCCacheTile>("QGCCacheTile");

(void) connect(m_worker, &QGCCacheWorker::updateTotals, this, &QGCMapEngine::_updateTotals);
// m_worker->moveToThread(m_thread);
(void) connect(m_worker, &QGCCacheWorker::updateTotals, this, &QGCMapEngine::_updateTotals, Qt::AutoConnection);
// m_thread->start();
}

QGCMapEngine::~QGCMapEngine()
{
(void) disconnect(m_worker);
m_worker->quit();
m_worker->wait();
(void) QMetaObject::invokeMethod(m_worker, "stop", Qt::AutoConnection);
m_worker->stop();
(void) m_worker->wait();

// qCDebug(QGCMapEngineLog) << Q_FUNC_INFO << this;
}
Expand Down Expand Up @@ -96,7 +102,7 @@ void QGCMapEngine::init()
m_cachePath = cacheDir;
if (!m_cachePath.isEmpty()) {
const QString databaseFilePath(m_cachePath + "/" + QGeoFileTileCacheQGC::getCacheFilename());
m_worker->setDatabaseFile(databaseFilePath);
m_worker->setDatabaseFilePath(databaseFilePath);

qCDebug(QGCMapEngineLog) << "Map Cache in:" << databaseFilePath;
} else {
Expand All @@ -115,7 +121,9 @@ void QGCMapEngine::init()

bool QGCMapEngine::addTask(QGCMapTask *task)
{
return m_worker->enqueueTask(task);
bool result;
(void) QMetaObject::invokeMethod(m_worker, "enqueueTask", Qt::AutoConnection, qReturnArg(result), task);
return result;
}

bool QGCMapEngine::_wipeDirectory(const QString &dirPath)
Expand Down
2 changes: 2 additions & 0 deletions src/QtLocationPlugin/QGCMapEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Q_DECLARE_LOGGING_CATEGORY(QGCMapEngineLog)

class QGCMapTask;
class QGCCacheWorker;
class QThread;

class QGCMapEngine : public QObject
{
Expand Down Expand Up @@ -57,6 +58,7 @@ private slots:
bool m_prunning = false;
bool m_cacheWasReset = false;
QString m_cachePath;
QThread *m_thread = nullptr;
};

QGCMapEngine* getQGCMapEngine();
Loading

0 comments on commit 7881fd2

Please sign in to comment.