Hi

>> 2014-08-19 22:48 GMT+02:00 Nyall Dawson <nyall.daw...@gmail.com>:
>>> >
>>>
>>> Does it make any difference if you change:
>>> c = QgsComposition(QgsMapSettings())
>>>
>>> To:
>>> ms=QgsMapSettings()
>>> c=QgsComposition(ms)
>>>
>>> ?
>
> Martin/other python experts,
>
> What's the best way to fix this? Is /Transfer/ appropriate, given that the
> c++ code would never delete this object? Or is there an alternative sip flag
> which is more appropriate for this?

I think this is really API problem rather than Python-specific issue.
The QgsComposition is designed in a way that it always had
QgsMapRenderer from map canvas accessible (now changed to
QgsMapSettings). Worst of all, it is supposed to be the same instance
as used by map canvas - so it keeps just reference/pointer to
QgsMapSettings/QgsMapRenderer. The QgsComposition should be fixed so
that it does not require QgsMapSettings/QgsMapRenderer - after all, it
does not make much sense, there may be several composer map items with
different configuration. Each QgsComposerMap should have its own
QgsMapSettings instance.

The root of the problem here is that the QgsMapSettings() will create
an instance and then destroy it - while QgsComposition just keeps
blindly using dead reference. /Transfer/ or other annotations will
IMHO not solve the problem. I would consider is as a known issue and
live with it until API is not fixed.

Btw. using "c = QgsComposition( QgsMapRenderer() )" is also wrong
because of the same reasons. If it worked, it was just luck :-)

Regards
Martin
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to