Skip to content

Commit 89ea819

Browse files
committedFeb 6, 2019
Make sure Python wrappers of quasi-singletons are kept alive
If they are deleted, any other python wrappers which have been parented to these singletons are deleted too. One of the most common issues with this is, that subclasses of registry items are deleted and lost.
1 parent 7f0ab8b commit 89ea819

File tree

6 files changed

+36
-36
lines changed

6 files changed

+36
-36
lines changed
 

‎python/analysis/auto_generated/qgsanalysis.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ related to analysis classes.
3232
Returns a pointer to the singleton instance.
3333
%End
3434

35-
static QgsGeometryCheckRegistry *geometryCheckRegistry();
35+
static QgsGeometryCheckRegistry *geometryCheckRegistry() /KeepReference/;
3636
%Docstring
3737
Returns the global geometry checker registry, used for managing all geometry check factories.
3838
%End

‎python/core/auto_generated/qgsapplication.sip.in

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,29 +613,29 @@ wide background task handling.
613613
.. versionadded:: 3.0
614614
%End
615615

616-
static QgsColorSchemeRegistry *colorSchemeRegistry();
616+
static QgsColorSchemeRegistry *colorSchemeRegistry() /KeepReference/;
617617
%Docstring
618618
Returns the application's color scheme registry, used for managing color schemes.
619619

620620
.. versionadded:: 3.0
621621
%End
622622

623-
static QgsPaintEffectRegistry *paintEffectRegistry();
623+
static QgsPaintEffectRegistry *paintEffectRegistry() /KeepReference/;
624624
%Docstring
625625
Returns the application's paint effect registry, used for managing paint effects.
626626

627627
.. versionadded:: 3.0
628628
%End
629629

630-
static QgsRendererRegistry *rendererRegistry();
630+
static QgsRendererRegistry *rendererRegistry() /KeepReference/;
631631
%Docstring
632632
Returns the application's renderer registry, used for managing vector layer renderers.
633633

634634
.. versionadded:: 3.0
635635
%End
636636

637637

638-
static QgsDataItemProviderRegistry *dataItemProviderRegistry();
638+
static QgsDataItemProviderRegistry *dataItemProviderRegistry() /KeepReference/;
639639
%Docstring
640640
Returns the application's data item provider registry, which keeps a list of data item
641641
providers that may add items to the browser tree.
@@ -662,14 +662,14 @@ Returns the application's image cache, used for caching resampled versions of ra
662662
.. versionadded:: 3.6
663663
%End
664664

665-
static QgsNetworkContentFetcherRegistry *networkContentFetcherRegistry();
665+
static QgsNetworkContentFetcherRegistry *networkContentFetcherRegistry() /KeepReference/;
666666
%Docstring
667667
Returns the application's network content registry used for fetching temporary files during QGIS session
668668

669669
.. versionadded:: 3.2
670670
%End
671671

672-
static QgsValidityCheckRegistry *validityCheckRegistry();
672+
static QgsValidityCheckRegistry *validityCheckRegistry() /KeepReference/;
673673
%Docstring
674674
Returns the application's validity check registry, used for managing validity checks.
675675

@@ -740,7 +740,7 @@ Returns the application's page size registry, used for managing layout page size
740740
%End
741741

742742

743-
static QgsActionScopeRegistry *actionScopeRegistry();
743+
static QgsActionScopeRegistry *actionScopeRegistry() /KeepReference/;
744744
%Docstring
745745
Returns the action scope registry.
746746

@@ -754,19 +754,19 @@ Returns the application runtime profiler.
754754
.. versionadded:: 3.0
755755
%End
756756

757-
static QgsFieldFormatterRegistry *fieldFormatterRegistry();
757+
static QgsFieldFormatterRegistry *fieldFormatterRegistry() /KeepReference/;
758758
%Docstring
759759
Gets the registry of available field formatters.
760760
%End
761761

762-
static Qgs3DRendererRegistry *renderer3DRegistry();
762+
static Qgs3DRendererRegistry *renderer3DRegistry() /KeepReference/;
763763
%Docstring
764764
Returns registry of available 3D renderers.
765765

766766
.. versionadded:: 3.0
767767
%End
768768

769-
static QgsProjectStorageRegistry *projectStorageRegistry();
769+
static QgsProjectStorageRegistry *projectStorageRegistry() /KeepReference/;
770770
%Docstring
771771
Returns registry of available project storage implementations.
772772

‎python/gui/auto_generated/qgsgui.sip.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Returns a pointer to the singleton instance.
3232
%End
3333

3434

35-
static QgsEditorWidgetRegistry *editorWidgetRegistry();
35+
static QgsEditorWidgetRegistry *editorWidgetRegistry() /KeepReference/;
3636
%Docstring
3737
Returns the global editor widget registry, used for managing all known edit widget factories.
3838
%End
3939

40-
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry();
40+
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry() /KeepReference/;
4141
%Docstring
4242
Returns the global source select provider registry, used for managing all known source select widget factories.
4343
%End
@@ -47,22 +47,22 @@ Returns the global source select provider registry, used for managing all known
4747
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
4848
%End
4949

50-
static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry();
50+
static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry() /KeepReference/;
5151
%Docstring
5252
Returns the global layer tree embedded widget registry, used for registering widgets that may be embedded into layer tree view.
5353
%End
5454

55-
static QgsMapLayerActionRegistry *mapLayerActionRegistry();
55+
static QgsMapLayerActionRegistry *mapLayerActionRegistry() /KeepReference/;
5656
%Docstring
5757
Returns the global map layer action registry, used for registering map layer actions.
5858
%End
5959

60-
static QgsLayoutItemGuiRegistry *layoutItemGuiRegistry();
60+
static QgsLayoutItemGuiRegistry *layoutItemGuiRegistry() /KeepReference/;
6161
%Docstring
6262
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
6363
%End
6464

65-
static QgsProcessingGuiRegistry *processingGuiRegistry();
65+
static QgsProcessingGuiRegistry *processingGuiRegistry() /KeepReference/;
6666
%Docstring
6767
Returns the global processing gui registry, used for registering the GUI behavior of processing algorithms.
6868

@@ -76,7 +76,7 @@ Returns the global processing recent algorithm log, used for tracking recently u
7676
.. versionadded:: 3.4
7777
%End
7878

79-
static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry();
79+
static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry() /KeepReference/;
8080
%Docstring
8181
Returns the global data item GUI provider registry, used for tracking providers which affect the browser
8282
GUI.

‎src/analysis/qgsanalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ANALYSIS_EXPORT QgsAnalysis
4949
/**
5050
* Returns the global geometry checker registry, used for managing all geometry check factories.
5151
*/
52-
static QgsGeometryCheckRegistry *geometryCheckRegistry();
52+
static QgsGeometryCheckRegistry *geometryCheckRegistry() SIP_KEEPREFERENCE;
5353

5454
private:
5555

‎src/core/qgsapplication.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,19 +549,19 @@ class CORE_EXPORT QgsApplication : public QApplication
549549
* Returns the application's color scheme registry, used for managing color schemes.
550550
* \since QGIS 3.0
551551
*/
552-
static QgsColorSchemeRegistry *colorSchemeRegistry();
552+
static QgsColorSchemeRegistry *colorSchemeRegistry() SIP_KEEPREFERENCE;
553553

554554
/**
555555
* Returns the application's paint effect registry, used for managing paint effects.
556556
* \since QGIS 3.0
557557
*/
558-
static QgsPaintEffectRegistry *paintEffectRegistry();
558+
static QgsPaintEffectRegistry *paintEffectRegistry() SIP_KEEPREFERENCE;
559559

560560
/**
561561
* Returns the application's renderer registry, used for managing vector layer renderers.
562562
* \since QGIS 3.0
563563
*/
564-
static QgsRendererRegistry *rendererRegistry();
564+
static QgsRendererRegistry *rendererRegistry() SIP_KEEPREFERENCE;
565565

566566
/**
567567
* Returns the application's raster renderer registry, used for managing raster layer renderers.
@@ -575,7 +575,7 @@ class CORE_EXPORT QgsApplication : public QApplication
575575
* providers that may add items to the browser tree.
576576
* \since QGIS 3.0
577577
*/
578-
static QgsDataItemProviderRegistry *dataItemProviderRegistry();
578+
static QgsDataItemProviderRegistry *dataItemProviderRegistry() SIP_KEEPREFERENCE;
579579

580580
/**
581581
* Returns the application's SVG cache, used for caching SVG images and handling parameter replacement
@@ -598,13 +598,13 @@ class CORE_EXPORT QgsApplication : public QApplication
598598
* Returns the application's network content registry used for fetching temporary files during QGIS session
599599
* \since QGIS 3.2
600600
*/
601-
static QgsNetworkContentFetcherRegistry *networkContentFetcherRegistry();
601+
static QgsNetworkContentFetcherRegistry *networkContentFetcherRegistry() SIP_KEEPREFERENCE;
602602

603603
/**
604604
* Returns the application's validity check registry, used for managing validity checks.
605605
* \since QGIS 3.6
606606
*/
607-
static QgsValidityCheckRegistry *validityCheckRegistry();
607+
static QgsValidityCheckRegistry *validityCheckRegistry() SIP_KEEPREFERENCE;
608608

609609
/**
610610
* Returns the application's symbol layer registry, used for managing symbol layers.
@@ -669,7 +669,7 @@ class CORE_EXPORT QgsApplication : public QApplication
669669
*
670670
* \since QGIS 3.0
671671
*/
672-
static QgsActionScopeRegistry *actionScopeRegistry();
672+
static QgsActionScopeRegistry *actionScopeRegistry() SIP_KEEPREFERENCE;
673673

674674
/**
675675
* Returns the application runtime profiler.
@@ -680,19 +680,19 @@ class CORE_EXPORT QgsApplication : public QApplication
680680
/**
681681
* Gets the registry of available field formatters.
682682
*/
683-
static QgsFieldFormatterRegistry *fieldFormatterRegistry();
683+
static QgsFieldFormatterRegistry *fieldFormatterRegistry() SIP_KEEPREFERENCE;
684684

685685
/**
686686
* Returns registry of available 3D renderers.
687687
* \since QGIS 3.0
688688
*/
689-
static Qgs3DRendererRegistry *renderer3DRegistry();
689+
static Qgs3DRendererRegistry *renderer3DRegistry() SIP_KEEPREFERENCE;
690690

691691
/**
692692
* Returns registry of available project storage implementations.
693693
* \since QGIS 3.2
694694
*/
695-
static QgsProjectStorageRegistry *projectStorageRegistry();
695+
static QgsProjectStorageRegistry *projectStorageRegistry() SIP_KEEPREFERENCE;
696696

697697
/**
698698
* This string is used to represent the value `NULL` throughout QGIS.

‎src/gui/qgsgui.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ class GUI_EXPORT QgsGui
6767
/**
6868
* Returns the global editor widget registry, used for managing all known edit widget factories.
6969
*/
70-
static QgsEditorWidgetRegistry *editorWidgetRegistry();
70+
static QgsEditorWidgetRegistry *editorWidgetRegistry() SIP_KEEPREFERENCE;
7171

7272
/**
7373
* Returns the global source select provider registry, used for managing all known source select widget factories.
7474
*/
75-
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry();
75+
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry() SIP_KEEPREFERENCE;
7676

7777
/**
7878
* Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
@@ -82,23 +82,23 @@ class GUI_EXPORT QgsGui
8282
/**
8383
* Returns the global layer tree embedded widget registry, used for registering widgets that may be embedded into layer tree view.
8484
*/
85-
static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry();
85+
static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry() SIP_KEEPREFERENCE;
8686

8787
/**
8888
* Returns the global map layer action registry, used for registering map layer actions.
8989
*/
90-
static QgsMapLayerActionRegistry *mapLayerActionRegistry();
90+
static QgsMapLayerActionRegistry *mapLayerActionRegistry() SIP_KEEPREFERENCE;
9191

9292
/**
9393
* Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
9494
*/
95-
static QgsLayoutItemGuiRegistry *layoutItemGuiRegistry();
95+
static QgsLayoutItemGuiRegistry *layoutItemGuiRegistry() SIP_KEEPREFERENCE;
9696

9797
/**
9898
* Returns the global processing gui registry, used for registering the GUI behavior of processing algorithms.
9999
* \since QGIS 3.2
100100
*/
101-
static QgsProcessingGuiRegistry *processingGuiRegistry();
101+
static QgsProcessingGuiRegistry *processingGuiRegistry() SIP_KEEPREFERENCE;
102102

103103
/**
104104
* Returns the global processing recent algorithm log, used for tracking recently used processing algorithms.
@@ -111,7 +111,7 @@ class GUI_EXPORT QgsGui
111111
* GUI.
112112
* \since QGIS 3.6
113113
*/
114-
static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry();
114+
static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry() SIP_KEEPREFERENCE;
115115

116116
/**
117117
* Register the widget to allow its position to be automatically saved and restored when open and closed.

0 commit comments

Comments
 (0)
Please sign in to comment.