From: msw Date: Thu, 29 Jul 1999 17:03:59 +0000 (+0000) Subject: corrected logic for tree countingalways return a python list for the selection, even... X-Git-Tag: r0-50~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=788ec6565951cfa96562dcc7a5a2c511ae7f0627;p=thirdparty%2Fnewt.git corrected logic for tree countingalways return a python list for the selection, even if it is an empty listwhat are these 'i' variables? nuke them --- diff --git a/checkboxtree.c b/checkboxtree.c index e9a490a..c698bcb 100644 --- a/checkboxtree.c +++ b/checkboxtree.c @@ -54,7 +54,7 @@ static int countItems(struct items * item, enum countWhat what) { while (item) { if ((!item->branch) || (what == COUNT_EXPOSED)) count++; - if (item->branch && (what == COUNT_EXPOSED && item->selected)) + if (item->branch || (what == COUNT_EXPOSED && item->selected)) count += countItems(item->branch, what); item = item->next; } diff --git a/snack.py b/snack.py index 9e1751f..8af5557 100644 --- a/snack.py +++ b/snack.py @@ -394,11 +394,9 @@ class CheckboxTree(Widget): def getSelection(self): selection = [] - i = 0 list = self.w.checkboxtreeGetSelection() for key in list: selection.append(self.key2item[key]) - i = i + 1 return selection diff --git a/snackmodule.c b/snackmodule.c index e482b17..b2cecc8 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -818,9 +818,10 @@ static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, selection = newtCheckboxTreeGetSelection(s->co, &numselected); + sel = PyList_New(0); + if (!selection) { - Py_INCREF(Py_None); - return Py_None; + return sel; } sel = PyList_New(0);