Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QtLocationPlugin: Update TileCacheWorker #11788

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -52,6 +54,7 @@ endif()
target_link_libraries(QGCLocation
PRIVATE
Qt6::Positioning
Qt6::Sql
QGC
Settings
Utilities
Expand All @@ -60,7 +63,6 @@ target_link_libraries(QGCLocation
Qt6::Location
Qt6::LocationPrivate
Qt6::Network
Qt6::Sql
QmlControls
)

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

#define CACHE_PATH_VERSION "300"

Expand All @@ -51,23 +52,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 +101,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 +120,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
Loading