Bug report #16858

Python error:RuntimeError: wrapped C/C++ object of type SnapGeometriesToLayer has been deleted

Added by Etienne Trimaille about 7 years ago. Updated almost 6 years ago.

Status:Closed
Priority:High
Assignee:Nyall Dawson
Category:Processing/QGIS
Affected QGIS version:master Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:24757

Description

While trying to launch the "Snap geometries to layer" in the processing toolbox, I got this python exception:

An error has occurred while executing Python code: 

RuntimeError: wrapped C/C++ object of type SnapGeometriesToLayer has been deleted 
Traceback (most recent call last):
  File "/Users/etienne/dev/c/build-QGIS-testing-creator/output/python/plugins/processing/algs/qgis/QgisAlgorithm.py", line 39, in shortHelpString
    return shortHelp.get(self.id(), None)
RuntimeError: wrapped C/C++ object of type SnapGeometriesToLayer has been deleted

Python version: 3.6.1 (default, Mar 23 2017, 16:49:06) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] 
QGIS version: 2.99.0-Master Master, exported 

Python Path:
/Users/etienne/dev/c/build-QGIS-testing-creator/output/python/plugins/processing
/Users/etienne/dev/c/build-QGIS-testing-creator/output/python
/Users/etienne/.qgis3/python
/Users/etienne/.qgis3/python/plugins
/Users/etienne/dev/c/build-QGIS-testing-creator/output/python/plugins
/Users/etienne/dev/c/build-QGIS-testing-creator/output/bin/$PYTHONPATH
/usr/local/opt/gdal2-python/lib/python3.6/site-packages
/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
/Users/etienne/.qgis3//python

I compiled QGIS today.

Associated revisions

Revision 370b2679
Added by Nyall Dawson almost 7 years ago

Fix wrapped c++ object has been deleted error when editing model parameters

Fixes #16858

Revision 87c1986c
Added by Nyall Dawson over 6 years ago

Improved memory managment of algorithm dialogs

Ensure that dialogs are always correctly deleted when appropriate.

Also, if an algorithm is running in a background task and hits
an error, we automatically re-show the algorithm dialog and the
associated log for debugging.

Fixes #16858

History

#1 Updated by Etienne Trimaille about 7 years ago

Hum, I have this error with every QGIS algorithms :

RuntimeError: wrapped C/C++ object of type GridPolygon has been deleted 
Traceback (most recent call last):
  File "/Users/etienne/dev/c/build-QGIS-testing-creator/output/python/plugins/processing/algs/qgis/QgisAlgorithm.py", line 39, in shortHelpString
    return shortHelp.get(self.id(), None)
RuntimeError: wrapped C/C++ object of type GridPolygon has been deleted

#2 Updated by Giovanni Manghi about 7 years ago

  • Priority changed from Normal to High

Etienne Trimaille wrote:

Hum, I have this error with every QGIS algorithms :

[...]

Nyall is working heavily on Processing in master, if there is a specific issue now on macOS I would let him know.

#3 Updated by Giovanni Manghi about 7 years ago

  • Regression? changed from No to Yes

#4 Updated by Giovanni Manghi about 7 years ago

  • Operating System deleted (MacOS)

Confirmed also on Windows. There are tools that just show the error message and other that show it but also open the tool dialog.

example:

Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\QgisAlgorithm.py", line 39, in shortHelpString
return shortHelp.get(self.id(), None)
RuntimeError: wrapped C/C++ object of type ImportIntoPostGIS has been deleted

#5 Updated by Giovanni Manghi about 7 years ago

seen the same also on Linux.

#6 Updated by Alexander Bruy about 7 years ago

This is known issue and we are working on it

#7 Updated by Nyall Dawson almost 7 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

#8 Updated by Etienne Trimaille almost 7 years ago

  • Status changed from Closed to Reopened

I got the issue again:

An error has occurred while executing Python code: 

RuntimeError: wrapped C/C++ object of type QgsProcessingParameterCrs has been deleted 
Traceback (most recent call last):
  File "/Users/etienne/dev/cpp/build-QGIS-QGIS_Build_Kit_QT5-Debug/output/python/plugins/processing/modeler/ModelerGraphicItem.py", line 428, in mousePressEvent
    self.action()
  File "/Users/etienne/dev/cpp/build-QGIS-QGIS_Build_Kit_QT5-Debug/output/python/plugins/processing/modeler/ModelerGraphicItem.py", line 201, in editElement
    self.element.setParameterName(dlg.param.name())
RuntimeError: wrapped C/C++ object of type QgsProcessingParameterCrs has been deleted

Python version: 3.6.2 (default, Jul 17 2017, 16:44:45) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] 
QGIS version: 2.99.0-Master Master, 3412afc400 

I could replicate most of the time, not always:
In the Processing modeler, create a new input parameter, close it, edit it and close it again. I can check how to replicate if needed

#9 Updated by Nyall Dawson almost 7 years ago

  • Status changed from Reopened to Feedback

I could replicate most of the time, not always:

In the Processing modeler, create a new input parameter, close it, edit it and close it again. I can check how to replicate if needed

Can't reproduce - can you post step by step instructions please! (also commit sha for your build)

#10 Updated by Nyall Dawson almost 7 years ago

Reproduced - it's when you close the dialog via the title bar close button, instead of using ok or cancel

#11 Updated by Nyall Dawson almost 7 years ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

#12 Updated by Etienne Trimaille almost 7 years ago

Thanks Nyall for the quick fix. I will check again.

#13 Updated by Etienne Trimaille over 6 years ago

  • Status changed from Closed to Reopened
  • Assignee changed from Victor Olaya to Nyall Dawson

The problem occurs again for me in the modeler.

Steps to reproduce:
  • Run a model
  • Close the dialog with the close button in the title bar while the model is running.
  • At the end of the model, there is an exception:
    RuntimeError: wrapped C/C++ object of type AlgorithmDialog has been deleted 
    Traceback (most recent call last):
      File "/Users/etienne/dev/cpp/build-QGIS-QGIS_Build_Kit_QT5-Debug/output/python/plugins/processing/gui/AlgorithmDialog.py", line 244, in on_complete
        feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
    RuntimeError: wrapped C/C++ object of type AlgorithmDialog has been deleted
    

Maybe when we click on the close button, a popup should come to ask if we want to cancel the algorithm or if we just want to close the dialog and the model should still run in the background?

Latest commit from master

#14 Updated by Nyall Dawson over 6 years ago

  • Status changed from Reopened to Closed

#15 Updated by Etienne Trimaille over 6 years ago

  • Status changed from Closed to Reopened

The problem occurs again! sorry. A fresh build from this morning: d7e18131808c3a622e5597cdf5608a28136755e7

New scenario:
In "Settings" "Options" "Processing" "Providers" and then toggle the activate on/off checkbox (saga, grass ...) then press OK. It seems the error is coming from ALL plugins having their own providers:

An error has occurred while executing Python code: 

RuntimeError: wrapped C/C++ object of type QueryFactoryAlgorithm has been deleted 
Traceback (most recent call last):
  File "/Users/etienne/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/src/quick_osm_processing/quick_osm_provider.py", line 74, in loadAlgorithms
    self.addAlgorithm(alg)
RuntimeError: wrapped C/C++ object of type QueryFactoryAlgorithm has been deleted


Thanks for previous fix.

#16 Updated by Nyall Dawson over 6 years ago

  • Status changed from Reopened to Feedback

I can't reproduce - is it still an issue?

#17 Updated by Etienne Trimaille over 6 years ago

Yes, I can replicate on master.

Maybe it's not with all Processing plugins.
The first message I have, it's coming from the "Buffer by percentage" plugin.
  • Install it.
  • You should see it in the Processing Toolbox.
  • Go into the processing settings.
  • Toggle Saga or Grass activation checkbox.
  • Press OK and the error is coming:
RuntimeError: wrapped C/C++ object of type BufferByFixedPercentage has been deleted 
Traceback (most recent call last):
  File "/Users/etienne/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/BufferByPercentage/bufferbypercentage.py", line 136, in loadAlgorithms
    self.addAlgorithm(alg)
RuntimeError: wrapped C/C++ object of type BufferByFixedPercentage has been deleted

Then after this error message, I have the same error but from my own plugin QuickOSM.

#18 Updated by Nyall Dawson over 6 years ago

  • Status changed from Feedback to Closed

Not a QGIS bug - it's a bug in the plugin. PR here: https://github.com/jdugge/BufferByPercentage/pull/14

#19 Updated by Johannes Kroeger almost 6 years ago

I just had this happen with https://github.com/root676/QNEAT3/issues/8

Is there no way to catch these? I feel that no plugin should be able to completely crash QGIS. :(

Also available in: Atom PDF