summaryrefslogtreecommitdiff
path: root/py/pykms
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-11-24 10:51:31 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-11-24 10:51:31 +0200
commitc13047e3f7674a5a05b107ef3fd97d9ff4165639 (patch)
tree161d1e36c62809810407d4f4b54bf65152443142 /py/pykms
parent650fb54ae66cb43f939034771f85d6afab86f1fb (diff)
pykms: keep Card alive until Blob is gone
Diffstat (limited to 'py/pykms')
-rw-r--r--py/pykms/pykmsbase.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp
index aae5ece..96ebe7a 100644
--- a/py/pykms/pykmsbase.cpp
+++ b/py/pykms/pykmsbase.cpp
@@ -105,12 +105,14 @@ void init_pykmsbase(py::module &m)
py::class_<Blob>(m, "Blob")
.def("__init__", [](Blob& instance, Card& card, py::buffer buf) {
- py::buffer_info info = buf.request();
- if (info.ndim != 1)
- throw std::runtime_error("Incompatible buffer dimension!");
+ py::buffer_info info = buf.request();
+ if (info.ndim != 1)
+ throw std::runtime_error("Incompatible buffer dimension!");
+
+ new (&instance) Blob(card, info.ptr, info.size * info.itemsize);
+ },
+ py::keep_alive<1, 3>()) // Keep Card alive until this is destructed
- new (&instance) Blob(card, info.ptr, info.size * info.itemsize);
- })
.def_property_readonly("data", &Blob::data)
// XXX pybind11 doesn't support a base object (DrmObject) with custom holder-type,