From 956f332e410331fde426e1485589d905cdf80fb1 Mon Sep 17 00:00:00 2001
From: David Winter <david.winter@analog.com>
Date: Mon, 9 Aug 2021 13:24:24 +0200
Subject: qtgui: Replace pyqwidget() with qwidget()

Previously, two versions of the `qtwidget` functions existed,
`qwidget()` and `pyqwidget()`, with the only difference being that
`qwidget()` returned a pointer to the `QWidget` object managed by the
corresponding block, while `pyqwidget()` returned that same pointer, but as
an integer (Or `PyLong` in this case).

While `qwidget()` is used by C++ code accessing the widgets,
`pyqwidget()` is only used for the python interface. This makes these
two methods redundant, thus this commit entirely removes `pyqwidget()`,
and modifies the `qwidget()` python wrapper to behave like
`pyqwidget()`. Note that we can be fairly confident that this change
will not effect potential users of `qwidget()`, because any invocation
on the objects previously returned by `qwidget()` would cause a
segmentation fault.

This commit also fixes a memory leak:

Internally, the `pyqwidget()` functions were returning a PyLong `PyObject *`,
which was then upwrapped in a pybind trampoline without decrementing
the reference count of that python object.

Signed-off-by: David Winter <david.winter@analog.com>
---
 gr-qtgui/examples/pyqt_histogram_f.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'gr-qtgui/examples/pyqt_histogram_f.py')

diff --git a/gr-qtgui/examples/pyqt_histogram_f.py b/gr-qtgui/examples/pyqt_histogram_f.py
index abe4353683..d35cc90cc9 100644
--- a/gr-qtgui/examples/pyqt_histogram_f.py
+++ b/gr-qtgui/examples/pyqt_histogram_f.py
@@ -164,7 +164,7 @@ class my_top_block(gr.top_block):
         self.ctrl_win.attach_signal2(src2)
 
         # Get the reference pointer to the SpectrumDisplayForm QWidget
-        pyQt  = self.snk1.pyqwidget()
+        pyQt  = self.snk1.qwidget()
 
         # Wrap the pointer as a PyQt SIP object
         # This can now be manipulated as a PyQt5.QtWidgets.QWidget
-- 
cgit v1.2.3