diff --git a/python/PyQt6/server/auto_generated/qgscapabilitiescache.sip.in b/python/PyQt6/server/auto_generated/qgscapabilitiescache.sip.in index 55f3f1db35a6..249c4c584275 100644 --- a/python/PyQt6/server/auto_generated/qgscapabilitiescache.sip.in +++ b/python/PyQt6/server/auto_generated/qgscapabilitiescache.sip.in @@ -39,9 +39,11 @@ Inserts new capabilities document (creates a copy of the document, does not take :param doc: the DOM document %End + public slots: + void removeCapabilitiesDocument( const QString &path ); %Docstring -Remove capabilities document +Removes capabilities document :param path: the project file path %End diff --git a/python/PyQt6/server/auto_generated/qgsconfigcache.sip.in b/python/PyQt6/server/auto_generated/qgsconfigcache.sip.in index a1ed747f785f..145e0cc54a21 100644 --- a/python/PyQt6/server/auto_generated/qgsconfigcache.sip.in +++ b/python/PyQt6/server/auto_generated/qgsconfigcache.sip.in @@ -78,6 +78,15 @@ Initialize from settings %End + signals: + + void projectRemovedFromCache( const QString &path ); +%Docstring +Emitted whenever a project is removed from the cache. + +.. versionadded:: 3.38 +%End + private: QgsConfigCache(); public slots: diff --git a/python/server/auto_generated/qgscapabilitiescache.sip.in b/python/server/auto_generated/qgscapabilitiescache.sip.in index 55f3f1db35a6..249c4c584275 100644 --- a/python/server/auto_generated/qgscapabilitiescache.sip.in +++ b/python/server/auto_generated/qgscapabilitiescache.sip.in @@ -39,9 +39,11 @@ Inserts new capabilities document (creates a copy of the document, does not take :param doc: the DOM document %End + public slots: + void removeCapabilitiesDocument( const QString &path ); %Docstring -Remove capabilities document +Removes capabilities document :param path: the project file path %End diff --git a/python/server/auto_generated/qgsconfigcache.sip.in b/python/server/auto_generated/qgsconfigcache.sip.in index a1ed747f785f..145e0cc54a21 100644 --- a/python/server/auto_generated/qgsconfigcache.sip.in +++ b/python/server/auto_generated/qgsconfigcache.sip.in @@ -78,6 +78,15 @@ Initialize from settings %End + signals: + + void projectRemovedFromCache( const QString &path ); +%Docstring +Emitted whenever a project is removed from the cache. + +.. versionadded:: 3.38 +%End + private: QgsConfigCache(); public slots: diff --git a/src/server/qgscapabilitiescache.h b/src/server/qgscapabilitiescache.h index cea69332b5ef..7ea9a0560444 100644 --- a/src/server/qgscapabilitiescache.h +++ b/src/server/qgscapabilitiescache.h @@ -53,8 +53,10 @@ class SERVER_EXPORT QgsCapabilitiesCache : public QObject */ void insertCapabilitiesDocument( const QString &configFilePath, const QString &key, const QDomDocument *doc ); + public slots: + /** - * Remove capabilities document + * Removes capabilities document * \param path the project file path */ void removeCapabilitiesDocument( const QString &path ); diff --git a/src/server/qgsconfigcache.cpp b/src/server/qgsconfigcache.cpp index 9c0728c96602..6731eb6fab81 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..b0910a34320a 100644 --- a/src/server/qgsconfigcache.h +++ b/src/server/qgsconfigcache.h @@ -128,6 +128,14 @@ class SERVER_EXPORT QgsConfigCache : public QObject //! Initialize with a strategy implementation. QgsConfigCache( QgsAbstractCacheStrategy *strategy ) SIP_SKIP; + signals: + + /** + * Emitted whenever a project is removed from the cache. + * \since QGIS 3.38 + */ + 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..52475fb5d5c3 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::removeCapabilitiesDocument ); + sInitialized = true; QgsMessageLog::logMessage( QStringLiteral( "Server initialized" ), QStringLiteral( "Server" ), Qgis::MessageLevel::Info ); return true;