#1 SingleRadioButton select() is broken
Closed: Fixed 4 years ago by mlichvar. Opened 6 years ago by terop.

The commit 7cdac0c broke SingleRadioButton select() method on 64 bit machine. The widget_get_radioValue() returns 32bit integer while it is compared to 64 bit key.

It can be fixed with the following patch:

diff --git a/snack.c b/snack.c
index 172c7d0..0f9f4e7 100644
--- a/snack.c
+++ b/snack.c
@@ -1096,7 +1101,11 @@ static PyObject * widget_get_radioValue(PyObject self, void closure)
{
snackWidget w = (snackWidget )self;

+#if SIZEOF_VOID_P <= SIZEOF_LONG
return Py_BuildValue("i", newtRadioGetCurrent(w->co));
+#else
+ return Py_BuildValue("L", newtRadioGetCurrent(w->co));
+#endif
}

static void widgetDestructor(PyObject * o) {


The provided patch does not seem to fix the issue after all.
However, the issue is still real. The radio button works still in 0.52.17

Does it work with this change?

--- a/snack.c
+++ b/snack.c
@@ -1096,7 +1096,11 @@ static PyObject * widget_get_radioValue(PyObject *self, void *closure)
 {
        snackWidget *w = (snackWidget *)self;

-       return Py_BuildValue("i", newtRadioGetCurrent(w->co));
+#if SIZEOF_VOID_P <= SIZEOF_LONG
+       return Py_BuildValue("l", (long)newtRadioGetCurrent(w->co));
+#else
+       return Py_BuildValue("L", (long long)newtRadioGetCurrent(w->co));
+#endif
 }

 static void widgetDestructor(PyObject * o) {

Metadata Update from @mlichvar:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata