Advertisement
hatrocketcoin

Example Process

Apr 23rd, 2021
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.61 KB | None | 0 0
  1. from PyQt5.QtCore import QCoreApplication, QVariant
  2. from qgis.core import (QgsProcessingUtils,
  3.                    QgsProcessing,
  4.                    QgsFeatureSink,
  5.                    QgsProject,
  6.                    QgsLayerTreeLayer,
  7.                    QgsFields,
  8.                    QgsField,
  9.                    QgsWkbTypes,
  10.                    QgsFeature,
  11.                    QgsGeometry,
  12.                    QgsFeatureRequest,
  13.                    QgsVectorLayer,
  14.                    QgsProcessingException,
  15.                    QgsProcessingAlgorithm,
  16.                    QgsProcessingParameterFeatureSource,
  17.                    QgsProcessingFeatureSourceDefinition,
  18.                    QgsProcessingParameterField,
  19.                    QgsProcessingParameterNumber,
  20.                    QgsProcessingParameterPoint,
  21.                    QgsProcessingParameterString,
  22.                    QgsProcessingParameterEnum,
  23.                    QgsProcessingParameterFeatureSink
  24.                    )
  25. import processing
  26. import sys
  27. from qgis.utils import iface
  28.  
  29. class crashexample(QgsProcessingAlgorithm):
  30.  
  31.     ORIG = 'ORIG'
  32.    
  33.     def createInstance(self):
  34.         return crashexample()
  35.  
  36.     def tr(self, string):
  37.         """
  38.        Returns a translatable string with the self.tr() function.
  39.        """
  40.         return QCoreApplication.translate('Processing', string)
  41.  
  42.     def name(self):
  43.         return 'crashexample'
  44.  
  45.     def displayName(self):
  46.         return self.tr('Crash Example')
  47.  
  48.     def group(self):
  49.         return self.tr('Debugging Scripts')
  50.  
  51.     def groupId(self):
  52.         return 'debuggingscripts'
  53.  
  54.     def shortHelpString(self):
  55.         return self.tr("<p>This script demonstrates a bug with version 3.16 (Hannover) whereby if you run this script manually it will be fine but if you run it using <b>processing.createAlgorithmDialog(\"script:crashexample\",{}).show()</b> via the python console QGIS on Windows 10 will crash. The crash will happen when you click the three dots to select the point on the map canvas. </p><p>Fault code in the Windows Event viewer should be: <br>Faulting application name: qgis-bin-g7.exe, version: 0.0.0.0, time stamp: 0x5f9304c8<br>Faulting module name: KERNELBASE.dll, version: 10.0.18362.1411, time stamp: 0xeb8644a5<br>Exception code: 0xc0000005<br>Fault offset: 0x0000000000043b29")
  56.                        
  57.     def initAlgorithm(self, config=None):
  58.         self.addParameter(QgsProcessingParameterPoint(self.ORIG, 'Origin coordinates',None,True))
  59.  
  60.     def processAlgorithm(self, parameters, context, feedback):
  61.         originPoint = self.parameterAsPoint(parameters, self.ORIG, context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement