NationalSecurityAgency / qgis-latlontools-plugin

QGIS tools to capture and zoom to coordinates using decimal, DMS, WKT, GeoJSON, MGRS, UTM, UPS, GEOREF, ECEF, H3, and Plus Codes notation. Provides external map support, MGRS & Plus Codes conversion and point digitizing tools.
GNU General Public License v2.0
298 stars 105 forks source link

Python error when reloading processing algorithms #17

Closed nirvn closed 5 years ago

nirvn commented 5 years ago

ATM, when the Lat Lon Tools plugin is installed & active, entering the QGIS settings window (to modify settings) and clicking on the [ OK ] button throws the following python error:

An error has occurred while executing Python code: 

RuntimeError: wrapped C/C++ object of type MGRStoLayerlgorithm has been deleted 
Traceback (most recent call last):
  File "/home/webmaster/.local/share/QGIS/QGIS3/profiles/default/python/plugins/latlontools/provider.py", line 20, in loadAlgorithms
    self.addAlgorithm( alg )
RuntimeError: wrapped C/C++ object of type MGRStoLayerlgorithm has been deleted

This is because the plugin code tries to add algorithm objects (created in the def init(self) function that have been deleted during the processing algorithms' reload process.

To fix this, simply move this line (https://github.com/NationalSecurityAgency/qgis-latlontools-plugin/blob/master/provider.py#L13) into the def loadAlgorithms(self) function (https://github.com/NationalSecurityAgency/qgis-latlontools-plugin/blob/master/provider.py#L18), that'll fix the error (which can actually cause QGIS to crash randomly).

nirvn commented 5 years ago

@nyalldawson 's PR #18 does that :)

hamiltoncj commented 5 years ago

@nirvn @nyalldawson Lat Lon Tools 3.0.16 is now available. Please check to see if it solves this problem.

Thanks!!!

nirvn commented 5 years ago

Yep, issue solved. Thanks for the fix @nyalldawson , and the quick reaction @hamiltoncj .