Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling QgsPathResolver.setPathPreprocessor causes python to abort #58112

Open
2 tasks done
rbrooklyn opened this issue Jul 15, 2024 · 3 comments
Open
2 tasks done

Calling QgsPathResolver.setPathPreprocessor causes python to abort #58112

rbrooklyn opened this issue Jul 15, 2024 · 3 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@rbrooklyn
Copy link

rbrooklyn commented Jul 15, 2024

What is the bug or the crash?

Calling QgsPathResolver.setPathPreprocessor() causes Python to abort without any error message.

This has been observed on version 3.34.8 and 3.34.7 for Windows 10 on two different machines.

This has worked absolutely fine 3.28.x for Windows 10 in the past. I've only noticed an issue when updating QGIS and running existing scripts.

Steps to reproduce the issue

Create Test.py with the following contents:

from qgis.core import QgsApplication, QgsProject, QgsLayoutExporter, QgsPathResolver
from osgeo import gdal
import os
import sys

def my_path_processor(path):
print(f"my_path_processor() called with {{path}}")

qgs = QgsApplication([], False)
print("1")
qgs.initQgis()
print("2")
QgsPathResolver.setPathPreprocessor(my_path_processor)
print("3")
qgs.exitQgis()
print("4")

Run C:\Program Files\QGIS 3.34.8\bin\python-qgis-ltr.bat .\Test.py

Output should be:

1
2
3
4

Output is actually

1
2

As when the "QgsPathResolver.setPathPreprocessor(my_path_processor)" line is called then python closes without proceeding so the print lines for 3 and 4 are never called.

Versions

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.34.8-Prizren QGIS code revision 9164233
Qt version 5.15.13
Python version 3.12.4
GDAL/OGR version 3.9.0
PROJ version 9.4.0
EPSG Registry database version v11.004 (2024-02-24)
GEOS version 3.12.2-CAPI-1.18.2
SQLite version 3.45.1
PDAL version 2.6.3
PostgreSQL client version 16.2
SpatiaLite version 5.1.0
QWT version 6.2.0
QScintilla2 version 2.14.1
OS version Windows Server 2022 Version 2009
       
Active Python plugins
changeDataSource 3.1
db_manager 0.1.20
grassprovider 2.12.99
MetaSearch 0.3.6
processing 2.12.99
QGIS version 3.34.8-Prizren QGIS code revision [9164233](https://github.com/qgis/QGIS/commit/91642333) Qt version 5.15.13 Python version 3.12.4 GDAL/OGR version 3.9.0 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version 16.2 SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows Server 2022 Version 2009

Active Python plugins
changeDataSource
3.1
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.6
processing
2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@rbrooklyn rbrooklyn added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 15, 2024
@rbrooklyn
Copy link
Author

Test.py file attached for reference. Remove .txt suffix as github wouldn't allow a .py suffixed file.
Test.py.txt

@rbrooklyn
Copy link
Author

Bit more testing today. Looks like this works very well in 3.38.0

Running & "C:\Program Files\QGIS 3.38.0\bin\python-qgis.bat" .\Test.py in powershell produced the expected result.

Running my actual scripts against 3.38.0 also worked without issue. I'd prefer to use the LTR version if possible, and this probably still needs fixing, but this is a workaround

@dmarteau
Copy link
Contributor

I Confirm that calling QgsPathResolver.setPathPreprocessor from python cause a segmentation fault

QGIS: 3.34.11 (ltr)
Ubuntu: 24.04
Python: 3.12.3

The method does not crash with QGIS 3.38.3 (release) on the same platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

No branches or pull requests

2 participants