Fix Python bindings for Connector::get_possible_crtcs() method
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 7 Dec 2017 16:06:40 +0000 (18:06 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 8 Dec 2017 06:48:03 +0000 (08:48 +0200)
The method returns an std::vector of DRMObject, which isn't supported by
the latest pybind11 as explained in commit 706a44abb3aa. Fix it by
wrapping the method manually.

Fixes: 706a44abb3aa ("Update to latest pybind11")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
py/pykms/pykmsbase.cpp

index 96ebe7a0858d375eabca40acf6a80559ebc0ca75..79c502ccc8aebfcb381ff8742237c16d1f33df3a 100644 (file)
@@ -54,7 +54,12 @@ void init_pykmsbase(py::module &m)
                        .def_property_readonly("fullname", &Connector::fullname)
                        .def("get_default_mode", &Connector::get_default_mode)
                        .def("get_current_crtc", &Connector::get_current_crtc)
-                       .def("get_possible_crtcs", &Connector::get_possible_crtcs)
+                       .def("get_possible_crtcs", [](Connector* self) {
+                               vector<unique_ptr<Crtc, py::nodelete>> v;
+                               for (Crtc* p : self->get_possible_crtcs())
+                                       v.push_back(unique_ptr<Crtc, py::nodelete>(p));
+                               return v;
+                       })
                        .def("get_modes", &Connector::get_modes)
                        .def("get_mode", (Videomode (Connector::*)(const string& mode) const)&Connector::get_mode)
                        .def("get_mode", (Videomode (Connector::*)(unsigned xres, unsigned yres, float refresh, bool ilace) const)&Connector::get_mode)