From 5e61fa31566f3706c1dd8d8c2b7f678bac0d4127 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Wed, 21 Aug 2024 10:00:55 +0700 Subject: [PATCH] Add pre 3.20 compatibility to fix --- libqfieldsync/layer.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libqfieldsync/layer.py b/libqfieldsync/layer.py index bf45a8a..f0f1727 100644 --- a/libqfieldsync/layer.py +++ b/libqfieldsync/layer.py @@ -1138,14 +1138,22 @@ def convert_to_gpkg(self, target_path): options = QgsVectorFileWriter.SaveVectorOptions() options.fileEncoding = "UTF-8" options.driverName = "GPKG" - ( - error, - error_msg, - returned_dest_file, - returned_dest_layer, - ) = QgsVectorFileWriter.writeAsVectorFormatV3( - source_layer, dest_file, QgsCoordinateTransformContext(), options - ) + if Qgis.QGIS_VERSION_INT > 32000: + ( + error, + error_msg, + returned_dest_file, + returned_dest_layer, + ) = QgsVectorFileWriter.writeAsVectorFormatV3( + source_layer, dest_file, QgsCoordinateTransformContext(), options + ) + else: + ( + error, + returned_dest_file, + ) = QgsVectorFileWriter.writeAsVectorFormatV2( + source_layer, dest_file, QgsCoordinateTransformContext(), options + ) if error != QgsVectorFileWriter.NoError: return if returned_dest_file: