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
3838%End
3939
4040
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+
4147 QgsProcessingContext::Flags flags() const;
4248%Docstring
4349 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
6666 // ! QgsProcessingContext cannot be copied
6767 QgsProcessingContext &operator =( const QgsProcessingContext &other ) = delete ;
6868
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+
6985 /* *
7086 * Returns any flags set in the context.
7187 * \see setFlags()
Original file line number Diff line number Diff line change @@ -583,6 +583,13 @@ void TestQgsProcessing::context()
583583 context.setInvalidGeometryCheck ( QgsFeatureRequest::GeometrySkipInvalid );
584584 QCOMPARE ( context.invalidGeometryCheck (), QgsFeatureRequest::GeometrySkipInvalid );
585585
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+
586593 // layers to load on completion
587594 QgsVectorLayer *v1 = new QgsVectorLayer ( " Polygon" , " V1" , " memory" );
588595 QgsVectorLayer *v2 = new QgsVectorLayer ( " Polygon" , " V2" , " memory" );
You can’t perform that action at this time.
0 commit comments