Skip to content

Commit

Permalink
Merge pull request qgis#56923 from pblottiere/fix_capabilities_cache
Browse files Browse the repository at this point in the history
Remove the corresponding capabilities doc in cache when a project is removed from cache
  • Loading branch information
troopa81 authored Mar 30, 2024
2 parents 8fd9166 + 2b00dc1 commit 800acb9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions python/PyQt6/server/auto_generated/qgsconfigcache.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion python/server/auto_generated/qgscapabilitiescache.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions python/server/auto_generated/qgsconfigcache.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/server/qgscapabilitiescache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions src/server/qgsconfigcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ void QgsConfigCache::removeEntry( const QString &path )
mXmlDocumentCache.remove( path );

mStrategy->entryRemoved( path );

emit projectRemovedFromCache( path );
}

// slots
Expand Down
8 changes: 8 additions & 0 deletions src/server/qgsconfigcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/server/qgsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 800acb9

Please sign in to comment.