Searchresults API

Andreas Monitzer pidgin at
Mon Jun 25 20:46:52 EDT 2007


I've been working on implementing the search results API into Adium  
this night. I've finished my viewer, but I have a memory management  
problem I can't quite solve.

notify_searchresults returns a pointer to my controller object, which  
owns the search result window. When additional results arrive, I can  
simply reference my object via the data parameter of  
notify_searchresults_new_rows. So far, that should work fine.
However, when the user closes the search results window, and  
afterwards notify_searchresults_new_rows gets called, I'd get a  
dangling pointer and the app would crash. There's no way to tell the  
API that I don't want to receive any further information.  
Additionally, I can't disallow closing the window until the search is  
complete, since there is no callback for that event (this also  
inhibits me keeping the controller object around until no more search  
results can pour in). I can't disallow further calls to  
notify_searchresults_new_rows (so that notify_searchresults would be  
called again), since I can't set my ui pointer to NULL in libpurple's  
data space. if it'd return NULL in the first place, this would be  
interpreted as an error result, and a error message would be displayed.

How is this API supposed to be used?


More information about the Devel mailing list