File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ class QgsProcessingContext
38
38
%End
39
39
40
40
41
+ void copyThreadSafeSettings( const QgsProcessingContext &other );
42
+ %Docstring
43
+ Copies all settings which are safe for use across different threads from
44
+ ``other`` to this context.
45
+ %End
46
+
41
47
QgsProcessingContext::Flags flags() const;
42
48
%Docstring
43
49
Returns any flags set in the context.
Original file line number Diff line number Diff line change @@ -66,6 +66,22 @@ class CORE_EXPORT QgsProcessingContext
66
66
// ! QgsProcessingContext cannot be copied
67
67
QgsProcessingContext &operator =( const QgsProcessingContext &other ) = delete ;
68
68
69
+ /* *
70
+ * Copies all settings which are safe for use across different threads from
71
+ * \a other to this context.
72
+ */
73
+ void copyThreadSafeSettings ( const QgsProcessingContext &other )
74
+ {
75
+ mFlags = other.mFlags ;
76
+ mProject = other.mProject ;
77
+ mExpressionContext = other.mExpressionContext ;
78
+ mInvalidGeometryCallback = other.mInvalidGeometryCallback ;
79
+ mInvalidGeometryCheck = other.mInvalidGeometryCheck ;
80
+ mTransformErrorCallback = other.mTransformErrorCallback ;
81
+ mDefaultEncoding = other.mDefaultEncoding ;
82
+ mFeedback = other.mFeedback ;
83
+ }
84
+
69
85
/* *
70
86
* Returns any flags set in the context.
71
87
* \see setFlags()
Original file line number Diff line number Diff line change @@ -583,6 +583,13 @@ void TestQgsProcessing::context()
583
583
context.setInvalidGeometryCheck ( QgsFeatureRequest::GeometrySkipInvalid );
584
584
QCOMPARE ( context.invalidGeometryCheck (), QgsFeatureRequest::GeometrySkipInvalid );
585
585
586
+ QgsProcessingContext context2;
587
+ context2.copyThreadSafeSettings ( context );
588
+ QCOMPARE ( context2.defaultEncoding (), context.defaultEncoding () );
589
+ QCOMPARE ( context2.invalidGeometryCheck (), context.invalidGeometryCheck () );
590
+ QCOMPARE ( context2.flags (), context.flags () );
591
+ QCOMPARE ( context2.project (), context.project () );
592
+
586
593
// layers to load on completion
587
594
QgsVectorLayer *v1 = new QgsVectorLayer ( " Polygon" , " V1" , " memory" );
588
595
QgsVectorLayer *v2 = new QgsVectorLayer ( " Polygon" , " V2" , " memory" );
You can’t perform that action at this time.
0 commit comments