[Qgis-developer] ASSERT: "smMainNAM" in file qgsnetworkaccessmanager.cpp, line 293

Richard Duivenvoorde rdmailings at duif.net
Sat Sep 24 00:29:13 PDT 2016


Trying to create a plugin which retrieves data in a separate thread
(worker class using QgsNetworkAccessManager to be sure I use QGIS
network settings), AND make that worker class testable.

I happen to hit the assertion:

ASSERT: "smMainNAM" in file qgsnetworkaccessmanager.cpp, line 293

everytime. I have initialized the python env ok, both in the working
thread, and/or in the main(testing) thread:

    QCoreApplication.setOrganizationName('QGIS')
    QCoreApplication.setApplicationName('QGIS2')
    QgsApplication.setPrefixPath(os.getenv("QGIS_PREFIX_PATH"), True)
    QgsApplication.setAuthDbDirPath('/home/richard/.qgis2/')
    app = QgsApplication(sys.argv, False)
    app.initQgis()

init is ok, I get the right output from for example:
    app.showSettings()
So I reckon the authentication db is found
but the ASSERT keeps going of as soon as I try to do:
    QgsNetworkAccessManager.instance()
To fire off a request in the worker thread.

Do you think it is the threading that is making this impossible for me?

What exactly is the assertion telling me?

Note that the PyQGIS initing info I have from

https://hub.qgis.org/issues/13494#note-19

Where Martin Dobias says:

"In general, the QgsApplication API is extremely confusing - and I hope
we can fix it for QGIS 3.0. It derives from QApplication (IMHO bad
idea), it also handles init/exit and paths. The init/exit handling
should be ideally completely automatic with PyQGIS, hopefully avoiding
different possible ways how people init PyQGIS in the future."

So I'm also wondering if any work is done in this QGIS 3.0 respect?
(because I think I hit this complexity now :-) )

Regards,

Richard Duivenvoorde


More information about the Qgis-developer mailing list