Skip to content

Commit 9d4adc1

Browse files
committed
Remove some singletons by moving instances to QgsApplication
- QgsColorSchemeRegistry - QgsDataItemProviderRegistry - QgsGPSConnectionRegistry - QgsMessageLog - QgsPaintEffectRegistry - QgsPluginLayerRegistry - QgsRasterRendererRegistry - QgsRendererRegistry - QgsSvgCache - QgsSymbolLayerRegistry
1 parent 4b1cf80 commit 9d4adc1

96 files changed

Lines changed: 561 additions & 407 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎doc/api_break.dox‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ QgsColorRampShader {#qgis_api_break_3_0_QgsColorRampShader}
477477
- maximumColorCacheSize() and setMaximumColorCacheSize() were no longer used and are removed.
478478
- ColorRamp_TYPE enum was renamed to Type, and its value names decapitalized
479479

480+
QgsColorSchemeRegistry {#qgis_api_break_3_0_QgsColorSchemeRegistry}
481+
----------------------
482+
483+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::colorSchemeRegistry() to access an application-wide registry.
484+
480485

481486
QgsComposerArrow {#qgis_api_break_3_0_QgsComposerArrow}
482487
----------------
@@ -727,6 +732,12 @@ QgsDataItem {#qgis_api_break_3_0_QgsDataItem}
727732
- emitBeginInsertItems(), emitEndInsertItems(), emitBeginRemoveItems(), emitEndRemoveItems(), emitDataChanged(), emitStateChanged() have been removed.
728733
- Favourites was renamed to Favorites
729734

735+
QgsDataItemProviderRegistry {#qgis_api_break_3_0_QgsDataItemProviderRegistry}
736+
---------------------------
737+
738+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::dataItemProviderRegistry() to access an application-wide registry.
739+
740+
730741
QgsDataProvider {#qgis_api_break_3_0_QgsDataProvider}
731742
---------------
732743

@@ -986,6 +997,11 @@ QgsEditorWidgetFactory {#qgis_api_break_3_0_QgsEditorWidgetFactory}
986997
- `alignmentFlag` has been removed. Use QgsFieldFormatter::representValue() instead
987998
- `createCache` has been removed. Use QgsFieldFormatter::representValue() instead
988999

1000+
QgsGPSConnectionRegistry {#qgis_api_break_3_0_QgsGPSConnectionRegistry}
1001+
------------------------
1002+
1003+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::gpsConnectionRegistry() to access an application-wide registry.
1004+
9891005

9901006
QgsGraduatedRenderer {#qgis_api_break_3_0_QgsGraduatedRenderer}
9911007
--------------------
@@ -1208,6 +1224,12 @@ QgsMarkerSymbolLayer {#qgis_api_break_3_0_QgsMarkerSymbolLayer}
12081224
- bounds() is now pure virtual and must be implemented in all subclasses.
12091225

12101226

1227+
QgsMessageLog {#qgis_api_break_3_0_QgsMessageLog}
1228+
---------------------------
1229+
1230+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::messageLog() to access an application-wide log.
1231+
1232+
12111233
QgsMimeDataUtils {#qgis_api_break_3_0_QgsMimeDataUtils}
12121234
----------------
12131235

@@ -1258,6 +1280,11 @@ QgsNumericSortTreeWidgetItem {#qgis_api_break_3_0_QgsNumericSortTreeWidge
12581280
has improved sort capabilities including the ability to set custom sort values for items
12591281
and for forcing certain items to always sort on top.
12601282

1283+
QgsPaintEffectRegistry {#qgis_api_break_3_0_QgsPaintEffectRegistry}
1284+
----------------------
1285+
1286+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::paintEffectRegistry() to access an application-wide registry.
1287+
12611288

12621289
QgsPalettedRasterRenderer {#qgis_api_break_3_0_QgsPalettedRasterRenderer}
12631290
-------------------------
@@ -1300,6 +1327,12 @@ QgsPluginLayer {#qgis_api_break_3_0_QgsPluginLayer}
13001327
- createMapRenderer(): default implementation (which called plugin's draw() method) has been removed. Plugin layers must implement createMapRenderer().
13011328

13021329

1330+
QgsPluginLayerRegistry {#qgis_api_break_3_0_QgsPluginLayerRegistry}
1331+
----------------------
1332+
1333+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::pluginLayerRegistry() to access an application-wide registry.
1334+
1335+
13031336
QgsPointDisplacementRenderer {#qgis_api_break_3_0_QgsPointDisplacementRenderer}
13041337
----------------------------
13051338

@@ -1405,6 +1438,12 @@ be returned instead of a null pointer if no transformation is required.
14051438
- setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.
14061439

14071440

1441+
QgsRendererRegistry {#qgis_api_break_3_0_QgsRendererRegistry}
1442+
----------------------
1443+
1444+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::rendererRegistry() to access an application-wide registry.
1445+
1446+
14081447
QgsRendererWidget {#qgis_api_break_3_0_QgsRendererWidget}
14091448
-----------------
14101449

@@ -1486,6 +1525,7 @@ QgsSublayersDialog {#qgis_api_break_3_0_QgsSublayersDialog}
14861525
QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache}
14871526
-----------
14881527

1528+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::svgCache() to access an application-wide cache.
14891529
- containsParamsV2() was removed. Use containsParamsV3() instead.
14901530

14911531
QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
@@ -1519,6 +1559,11 @@ the variant which takes QgsSymbolRenderContext instead.
15191559
- evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature ) was removed. Use the variant which takes QgsSymbolRenderContext instead.
15201560
- expression() was removed. Use getDataDefinedProperty or evaluateDataDefinedProperty instead.
15211561

1562+
QgsSymbolLayerRegistry {#qgis_api_break_3_0_QgsSymbolLayerRegistry}
1563+
----------------------
1564+
1565+
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::symbolLayerRegistry() to access an application-wide registry.
1566+
15221567

15231568
QgsSymbolLayerWidget {#qgis_api_break_3_0_QgsSymbolLayerWidget}
15241569
--------------------

‎python/core/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def calculation_finished(exception, value=None):
246246
247247
task = QgsTask.fromFunction('my task', calculate,
248248
on_finished=calculation_finished)
249-
QgsTaskManager.instance().addTask(task)
249+
QgsApplication.taskManager().addTask(task)
250250
251251
"""
252252

‎python/core/effects/qgspainteffectregistry.sip‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class QgsPaintEffectRegistry
6767

6868
public:
6969

70-
/** Returns a reference to the singleton instance of the paint effect registry.
71-
*/
72-
static QgsPaintEffectRegistry* instance();
70+
QgsPaintEffectRegistry();
71+
~QgsPaintEffectRegistry();
7372

7473
/** Returns the metadata for a specific effect.
7574
* @param name unique string name for paint effect class
@@ -120,10 +119,6 @@ class QgsPaintEffectRegistry
120119
*/
121120
static bool isDefaultStack( QgsPaintEffect* effect );
122121

123-
protected:
124-
QgsPaintEffectRegistry();
125-
~QgsPaintEffectRegistry();
126-
127122
private:
128123
QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh );
129124
};

‎python/core/gps/qgsgpsconnectionregistry.sip‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class QgsGPSConnectionRegistry
66
#include <qgsgpsconnectionregistry.h>
77
%End
88
public:
9-
static QgsGPSConnectionRegistry* instance();
9+
QgsGPSConnectionRegistry();
1010
~QgsGPSConnectionRegistry();
1111

1212
/** Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again*/
@@ -16,9 +16,6 @@ class QgsGPSConnectionRegistry
1616

1717
QList< QgsGPSConnection *> connectionList() const;
1818

19-
protected:
20-
QgsGPSConnectionRegistry();
21-
2219
private:
2320

2421
QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh );

‎python/core/qgsapplication.sip‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,62 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
381381
*/
382382
static QgsTaskManager* taskManager();
383383

384+
/**
385+
* Returns the application's color scheme registry, used for managing color schemes.
386+
* @note added in QGIS 3.0
387+
*/
388+
static QgsColorSchemeRegistry* colorSchemeRegistry();
389+
390+
/**
391+
* Returns the application's paint effect registry, used for managing paint effects.
392+
* @note added in QGIS 3.0
393+
*/
394+
static QgsPaintEffectRegistry* paintEffectRegistry();
395+
396+
/**
397+
* Returns the application's renderer registry, used for managing vector layer renderers.
398+
* @note added in QGIS 3.0
399+
*/
400+
static QgsRendererRegistry* rendererRegistry();
401+
402+
/**
403+
* Returns the application's data item provider registry, which keeps a list of data item
404+
* providers that may add items to the browser tree.
405+
* @note added in QGIS 3.0
406+
*/
407+
static QgsDataItemProviderRegistry* dataItemProviderRegistry();
408+
409+
/**
410+
* Returns the application's SVG cache, used for caching SVG images and handling parameter replacement
411+
* within SVG files.
412+
* @note added in QGIS 3.0
413+
*/
414+
static QgsSvgCache* svgCache();
415+
416+
/**
417+
* Returns the application's symbol layer registry, used for managing symbol layers.
418+
* @note added in QGIS 3.0
419+
*/
420+
static QgsSymbolLayerRegistry* symbolLayerRegistry();
421+
422+
/**
423+
* Returns the application's GPS connection registry, used for managing GPS connections.
424+
* @note added in QGIS 3.0
425+
*/
426+
static QgsGPSConnectionRegistry* gpsConnectionRegistry();
427+
428+
/**
429+
* Returns the application's plugin layer registry, used for managing plugin layer types.
430+
* @note added in QGIS 3.0
431+
*/
432+
static QgsPluginLayerRegistry* pluginLayerRegistry();
433+
434+
/**
435+
* Returns the application's message log.
436+
* @note added in QGIS 3.0
437+
*/
438+
static QgsMessageLog* messageLog();
439+
384440
%If(ANDROID)
385441
//dummy method to workaround sip generation issue issue
386442
bool x11EventFilter ( XEvent * event );

‎python/core/qgscolorschemeregistry.sip‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class QgsColorSchemeRegistry
1414
%End
1515
public:
1616

17-
/** Returns the global instance pointer, creating the object on the first call.
18-
*/
19-
static QgsColorSchemeRegistry * instance();
20-
2117
/** Constructor for an empty color scheme registry
2218
*/
2319
QgsColorSchemeRegistry();

‎python/core/qgsdataitemproviderregistry.sip‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class QgsDataItemProviderRegistry
1111
#include <qgsdataitemproviderregistry.h>
1212
%End
1313
public:
14-
static QgsDataItemProviderRegistry * instance();
15-
14+
QgsDataItemProviderRegistry();
1615
~QgsDataItemProviderRegistry();
1716

1817
//! Get list of available providers
@@ -25,7 +24,7 @@ class QgsDataItemProviderRegistry
2524
void removeProvider( QgsDataItemProvider* provider );
2625

2726
private:
28-
QgsDataItemProviderRegistry();
27+
2928
QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh );
3029

3130
};

‎python/core/qgsmessagelog.sip‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class QgsMessageLog : QObject
55
%End
66

77
public:
8-
static QgsMessageLog *instance();
8+
QgsMessageLog();
99

1010
enum MessageLevel
1111
{
@@ -20,8 +20,6 @@ class QgsMessageLog : QObject
2020
signals:
2121
void messageReceived( const QString& message, const QString& tag, MessageLevel level );
2222

23-
private:
24-
QgsMessageLog();
2523
};
2624

2725

‎python/core/qgspluginlayerregistry.sip‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class QgsPluginLayerRegistry
3737

3838
public:
3939

40-
/** Means of accessing canonical single instance */
41-
static QgsPluginLayerRegistry* instance();
40+
QgsPluginLayerRegistry();
4241

4342
~QgsPluginLayerRegistry();
4443

@@ -62,8 +61,6 @@ class QgsPluginLayerRegistry
6261

6362
private:
6463

65-
/** Private since instance() creates it */
66-
QgsPluginLayerRegistry();
6764
QgsPluginLayerRegistry( const QgsPluginLayerRegistry& rh );
6865

6966
};

‎python/core/symbology-ng/qgsrendererregistry.sip‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class QgsRendererRegistry
100100

101101
public:
102102

103-
//! Returns a pointer to the QgsRendererRegistry singleton
104-
static QgsRendererRegistry* instance();
103+
QgsRendererRegistry();
104+
~QgsRendererRegistry();
105105

106106
//! Adds a renderer to the registry. Takes ownership of the metadata object.
107107
//! @param metadata renderer metadata
@@ -128,11 +128,6 @@ class QgsRendererRegistry
128128
//! @note added in QGIS 2.16
129129
QStringList renderersList( const QgsVectorLayer* layer ) const;
130130

131-
protected:
132-
//! protected constructor
133-
QgsRendererRegistry();
134-
~QgsRendererRegistry();
135-
136131
private:
137132
QgsRendererRegistry( const QgsRendererRegistry& rh );
138133
//QgsRendererRegistry& operator=( const QgsRendererRegistry& rh );

0 commit comments

Comments
 (0)