From 8894e5d93f463ef0490bc667f5574647ec5055e1 Mon Sep 17 00:00:00 2001 From: Blottiere Paul Date: Wed, 20 Mar 2024 23:05:23 +0100 Subject: [PATCH] Remove the corresponding capabilities doc in cache when a project is removed from cache --- src/server/qgscapabilitiescache.h | 6 ++++-- src/server/qgsconfigcache.cpp | 2 ++ src/server/qgsconfigcache.h | 3 +++ src/server/qgsserver.cpp | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/server/qgscapabilitiescache.h b/src/server/qgscapabilitiescache.h index cea69332b5ef..1963287ef9f2 100644 --- a/src/server/qgscapabilitiescache.h +++ b/src/server/qgscapabilitiescache.h @@ -59,6 +59,10 @@ class SERVER_EXPORT QgsCapabilitiesCache : public QObject */ void removeCapabilitiesDocument( const QString &path ); + public slots: + //! Removes changed entry from this cache + void removeChangedEntry( const QString &path ); + private: QHash< QString, QHash< QString, QDomDocument > > mCachedCapabilities; QHash< QString, QDateTime> mCachedCapabilitiesTimestamps; @@ -67,8 +71,6 @@ class SERVER_EXPORT QgsCapabilitiesCache : public QObject int mCacheSize; private slots: - //! Removes changed entry from this cache - void removeChangedEntry( const QString &path ); //! Remove outdated enties void removeOutdatedEntries(); }; diff --git a/src/server/qgsconfigcache.cpp b/src/server/qgsconfigcache.cpp index 9c0728c96602..c32c415f2d49 100644 --- a/src/server/qgsconfigcache.cpp +++ b/src/server/qgsconfigcache.cpp @@ -249,6 +249,8 @@ void QgsConfigCache::removeEntry( const QString &path ) mXmlDocumentCache.remove( path ); mStrategy->entryRemoved( path ); + + emit projectRemovedFromCache(path); } // slots diff --git a/src/server/qgsconfigcache.h b/src/server/qgsconfigcache.h index 00fe0adcdf88..b4b956ca1527 100644 --- a/src/server/qgsconfigcache.h +++ b/src/server/qgsconfigcache.h @@ -128,6 +128,9 @@ class SERVER_EXPORT QgsConfigCache : public QObject //! Initialize with a strategy implementation. QgsConfigCache( QgsAbstractCacheStrategy *strategy ) SIP_SKIP; + signals: + void projectRemovedFromCache( const QString &path ); + private: // SIP require this QgsConfigCache() SIP_FORCE; diff --git a/src/server/qgsserver.cpp b/src/server/qgsserver.cpp index 37cb497b60ef..f52871493af9 100644 --- a/src/server/qgsserver.cpp +++ b/src/server/qgsserver.cpp @@ -368,6 +368,8 @@ bool QgsServer::init() // Initialize config cache QgsConfigCache::initialize( sSettings ); + QObject::connect(QgsConfigCache::instance(), &QgsConfigCache::projectRemovedFromCache, sCapabilitiesCache, &QgsCapabilitiesCache::removeChangedEntry); + sInitialized = true; QgsMessageLog::logMessage( QStringLiteral( "Server initialized" ), QStringLiteral( "Server" ), Qgis::MessageLevel::Info ); return true;