Navigation Menu

Skip to content

Commit

Permalink
Singleton, code cleanups, more tests, error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jan 20, 2021
1 parent 5bdabd3 commit 3024694
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 154 deletions.
5 changes: 5 additions & 0 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -789,9 +789,14 @@ Returns the application's classification methods registry, used in graduated ren
%Docstring
Returns the application's bookmark manager, used for storing installation-wide bookmarks.

.. note::

not available in Python bindings

.. versionadded:: 3.10
%End


static QgsStyleModel *defaultStyleModel();
%Docstring
Returns a shared QgsStyleModel containing the default style library (see :py:func:`QgsStyle.defaultStyle()`).
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -51,6 +51,7 @@
#include "qgsmessagelog.h"
#include "qgsannotationregistry.h"
#include "qgssettings.h"
#include "qgstiledownloadmanager.h"
#include "qgsunittypes.h"
#include "qgsuserprofile.h"
#include "qgsuserprofilemanager.h"
Expand Down Expand Up @@ -2276,6 +2277,11 @@ QgsBookmarkManager *QgsApplication::bookmarkManager()
return members()->mBookmarkManager;
}

QgsTileDownloadManager *QgsApplication::tileDownloadManager()
{
return members()->mTileDownloadManager;
}

QgsStyleModel *QgsApplication::defaultStyleModel()
{
return members()->mStyleModel;
Expand Down Expand Up @@ -2492,6 +2498,11 @@ QgsApplication::ApplicationMembers::ApplicationMembers()
mBookmarkManager = new QgsBookmarkManager( nullptr );
profiler->end();
}
{
profiler->start( tr( "Setup tile download manager" ) );
mTileDownloadManager = new QgsTileDownloadManager();
profiler->end();
}
{
profiler->start( tr( "Setup scalebar registry" ) );
mScaleBarRendererRegistry = new QgsScaleBarRendererRegistry();
Expand All @@ -2502,6 +2513,7 @@ QgsApplication::ApplicationMembers::ApplicationMembers()
QgsApplication::ApplicationMembers::~ApplicationMembers()
{
delete mStyleModel;
delete mTileDownloadManager;
delete mScaleBarRendererRegistry;
delete mValidityCheckRegistry;
delete mActionScopeRegistry;
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -64,6 +64,7 @@ class QgsConnectionRegistry;
class QgsScaleBarRendererRegistry;
class Qgs3DSymbolRegistry;
class QgsPointCloudRendererRegistry;
class QgsTileDownloadManager;

/**
* \ingroup core
Expand Down Expand Up @@ -733,10 +734,17 @@ class CORE_EXPORT QgsApplication : public QApplication

/**
* Returns the application's bookmark manager, used for storing installation-wide bookmarks.
* \note not available in Python bindings
* \since QGIS 3.10
*/
static QgsBookmarkManager *bookmarkManager();

/**
* Returns the application's tile download manager, used for download of map tiles when rendering.
* \since QGIS 3.18
*/
static QgsTileDownloadManager *tileDownloadManager() SIP_SKIP;

/**
* Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
*
Expand Down Expand Up @@ -1010,6 +1018,7 @@ class CORE_EXPORT QgsApplication : public QApplication
QgsAnnotationItemRegistry *mAnnotationItemRegistry = nullptr;
QgsUserProfileManager *mUserConfigManager = nullptr;
QgsBookmarkManager *mBookmarkManager = nullptr;
QgsTileDownloadManager *mTileDownloadManager = nullptr;
QgsStyleModel *mStyleModel = nullptr;
QString mNullRepresentation;
QStringList mSvgPathCache;
Expand Down

0 comments on commit 3024694

Please sign in to comment.