Bug report #18723
Adding a new function expression that also prints in the console halts QGIS
| Status: | Closed | ||
|---|---|---|---|
| Priority: | Normal | ||
| Assignee: | - | ||
| Category: | PyQGIS Console | ||
| Affected QGIS version: | 3.1(master) | Regression?: | No |
| Operating System: | Debian Buster | Easy fix?: | No |
| Pull Request or Patch supplied: | No | Resolution: | invalid |
| Crashes QGIS or corrupts data: | Yes | Copied to github as #: | 26610 |
Description
I have a point layer with 3 points.
I created the following function:
from qgis.core import *
from qgis.gui import *
from random import uniform
@qgsfunction(args='auto', group='QTIBIA Engineering')
def random_records(value1, value2, feature, parent):
"""
Generates a random value..
"""
print(value1, value2)
return uniform(value1, value2)
If I put in the layer label: uniform(0, 100.5) QGIS halts on the third print.
So, printing from the function halts QGIS.
History
#1
Updated by Nyall Dawson over 7 years ago
- Resolution set to invalid
- Status changed from Open to Closed
This isn't safe to do - better to use the thread safe qgis logger classes, e.g. QgsLogger, QgsMessageLog