diff --git a/examples/ex1_idaapi.py b/examples/ex1_idaapi.py index 8902ab8..4729554 100644 --- a/examples/ex1_idaapi.py +++ b/examples/ex1_idaapi.py @@ -15,7 +15,14 @@ def main(): seg = getseg(ea) # Loop from segment start to end - func = get_next_func(seg.startEA) + func_ea = seg.startEA + + # Get a function at the start of the segment (if any) + func = get_func(func_ea) + if func is None: + # No function there, try to get the next one + func = get_next_func(func_ea) + seg_end = seg.endEA while func is not None and func.startEA < seg_end: funcea = func.startEA diff --git a/pywraps.cpp b/pywraps.cpp index 7cafd3c..4abd294 100644 --- a/pywraps.cpp +++ b/pywraps.cpp @@ -1535,38 +1535,37 @@ bool pywraps_notify_when_t::notify_va(int slot, va_list va) in_notify = true; int old = slot == NW_OPENIDB_SLOT ? va_arg(va, int) : 0; + for ( ref_vec_t::iterator it = table[slot].begin(), it_end = table[slot].end(); + it != it_end; + ++it ) { - for ( ref_vec_t::iterator it = table[slot].begin(), it_end = table[slot].end(); - it != it_end; - ++it ) + // Form the notification code + newref_t py_code(PyInt_FromLong(1 << slot)); + ref_t py_result; + switch ( slot ) { - // Form the notification code - newref_t py_code(PyInt_FromLong(1 << slot)); - ref_t py_result; - switch ( slot ) - { - case NW_CLOSEIDB_SLOT: - case NW_INITIDA_SLOT: - case NW_TERMIDA_SLOT: - { - py_result = newref_t(PyObject_CallFunctionObjArgs(it->o, py_code.o, NULL)); - break; - } - case NW_OPENIDB_SLOT: - { - newref_t py_old(PyInt_FromLong(old)); - py_result = newref_t(PyObject_CallFunctionObjArgs(it->o, py_code.o, py_old.o, NULL)); - } + case NW_CLOSEIDB_SLOT: + case NW_INITIDA_SLOT: + case NW_TERMIDA_SLOT: + { + py_result = newref_t(PyObject_CallFunctionObjArgs(it->o, py_code.o, NULL)); break; - } - if ( PyW_GetError(&err) || py_result == NULL ) - { - PyErr_Clear(); - warning("notify_when(): Error occured while notifying object.\n%s", err.c_str()); - ok = false; - } + } + case NW_OPENIDB_SLOT: + { + newref_t py_old(PyInt_FromLong(old)); + py_result = newref_t(PyObject_CallFunctionObjArgs(it->o, py_code.o, py_old.o, NULL)); + } + break; + } + if ( PyW_GetError(&err) || py_result == NULL ) + { + PyErr_Clear(); + warning("notify_when(): Error occured while notifying object.\n%s", err.c_str()); + ok = false; } } + in_notify = false; // Process any delayed notify_when() calls that diff --git a/pywraps/py_kernwin_choose.py b/pywraps/py_kernwin_choose.py index 3924660..5923fcd 100644 --- a/pywraps/py_kernwin_choose.py +++ b/pywraps/py_kernwin_choose.py @@ -26,12 +26,14 @@ class Choose(object): if (flags & Choose2.CH_MODAL) == 0: self.refhack = self + def sizer(self): """ Callback: sizer - returns the length of the list """ return len(self.list) + def getl(self, n): """ Callback: getl - get one item from the list @@ -44,30 +46,10 @@ class Choose(object): return "" - def ins(self): - pass - - - def update(self, n): - pass - - - def edit(self, n): - pass - - def enter(self, n): print "enter(%d) called" % n - def destroy(self): - pass - - - def get_icon(self, n): - pass - - def choose(self): """ choose - Display the choose dialogue diff --git a/pywraps/py_kernwin_choose2.hpp b/pywraps/py_kernwin_choose2.hpp index a5733d2..03a5054 100644 --- a/pywraps/py_kernwin_choose2.hpp +++ b/pywraps/py_kernwin_choose2.hpp @@ -276,7 +276,7 @@ private: PYW_GIL_GET; pycall_res_t pyres(PyObject_CallMethod(self, (char *)S_ON_CLOSE, NULL)); - // Delete this instance if none modal and not embedded + // Delete this instance if non-modal and not embedded if ( !is_modal() && get_embedded() == NULL ) delete this; } diff --git a/pywraps/py_kernwin_choose2.py b/pywraps/py_kernwin_choose2.py index 2c949f7..4320bdc 100644 --- a/pywraps/py_kernwin_choose2.py +++ b/pywraps/py_kernwin_choose2.py @@ -87,7 +87,7 @@ class Choose2(object): """ Activates or creates a chooser window @param modal: Display as modal dialog - @return: For modal choosers it will return the selected item index (0-based) + @return: For modal choosers it will return the selected item index (0-based) or -1 if no selection """ if modal: self.flags |= Choose2.CH_MODAL @@ -207,17 +207,14 @@ class Choose2(object): # Triggered when the 'Refresh' is called from the popup menu item. # # @param n: The currently selected line (0-based) at the time of the refresh call -# @return: Return the number of elements +# @return: Return the new selected line # """ # return self.n # # def OnRefreshed(self): # """ # Triggered when a refresh happens (for example due to column sorting) -# @param n: Line number (0-based) -# @return: Return the number of elements # """ -# return self.n # # def OnCommand(self, n, cmd_id): # """Return int ; check add_chooser_command()"""