Commit b41a90bc authored by Jason Roehm's avatar Jason Roehm Committed by Dennis Nienhüser
Browse files

Fix to Python bindings for addLayer() and removeLayer()

MarbleWidget::addLayer() takes a pointer to a LayerInterface-derived
object as an argument. The pointer is added to an internal list of
layers that are rendered in the Marble widget. When exposing this
function via Python, the /Transfer/ SIP parameter annotation must be
supplied. This notation indicates to SIP that control of the lifetime
of the object passed via addLayer() is placed in the C++ library's
hands. If you don't do this, then Python might decide to
garbage-collect the layer object when it's no longer used on that side.
That is obviously a bad thing if the layer is still being used by the

Likewise, the /TransferBack/ annotation is used to return ownership of
the object back to Python if the removeLayer() function is later called
to remove the layer from the widget. At that time, the object can
safely be garbage-collected since it is no longer used by the widget
C++ library.

REVIEW: 104655
parent 07575fbd
......@@ -158,8 +158,8 @@ public:
void tileLevelChanged (int level);
void addLayer (Marble::LayerInterface* layer);
void removeLayer (Marble::LayerInterface* layer);
void addLayer (Marble::LayerInterface* layer /Transfer/);
void removeLayer (Marble::LayerInterface* layer /TransferBack/);
qreal radiusFromDistance (qreal distance) const;
qreal distanceFromRadius (qreal radius) const;
qreal zoomFromDistance (qreal distance) const;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment