aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-11-19 17:52:52 +0100
committermichael-west <michael.west@ettus.com>2020-12-01 12:59:42 -0800
commit4da7d5a946df34ae3461c524600e80ea8ab15f41 (patch)
treefb670cf98533c980d45c6067c8054db5fb48533c /host/lib
parentb82b99cc3eed90ee19f7149eefa4f5d02d4f5a21 (diff)
downloaduhd-4da7d5a946df34ae3461c524600e80ea8ab15f41.tar.gz
uhd-4da7d5a946df34ae3461c524600e80ea8ab15f41.tar.bz2
uhd-4da7d5a946df34ae3461c524600e80ea8ab15f41.zip
python: multi_usrp: Let get_tree() return a raw pointer
This changes the Python version of MultiUSRP.get_tree() such that it returns a raw pointer to the tree instead of returning the sptr. This fixes an issue where calling get_tree() will reliably cause a segfault during garbage collection, at least on some USRPs. The downside of this approach is that storing the return value from get_tree() can produce a dangling pointer when the underlying object is destroyed. It's still better than segfaults, and the recommended way to use get_tree() anyway is not to store the return value (unless it's in a local scope), but tack on property tree methods to get_tree() itself. Examples: >>> usrp = uhd.usrp.MultiUSRP('...') >>> usrp.get_tree().exists('/path/to/prop') # This is fine This change has no noticable API changes.
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/multi_usrp_python.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/host/lib/usrp/multi_usrp_python.cpp b/host/lib/usrp/multi_usrp_python.cpp
index 34bb96338..b26671760 100644
--- a/host/lib/usrp/multi_usrp_python.cpp
+++ b/host/lib/usrp/multi_usrp_python.cpp
@@ -29,7 +29,7 @@ void export_multi_usrp(py::module& m)
.def(py::init(&multi_usrp::make))
// clang-format off
- .def("get_tree" , &multi_usrp::get_tree)
+ .def("get_tree" , [](multi_usrp& self){ return self.get_tree().get(); }, py::return_value_policy::reference_internal)
// General USRP methods
.def("get_rx_freq" , &multi_usrp::get_rx_freq, py::arg("chan") = 0)