[Tcladdressbook-commits] Source TclAddressBook.c,1.34,1.35
Status: Alpha
Brought to you by:
bdesgraupes
|
From: Bernard D. <bde...@us...> - 2004-08-02 22:49:54
|
Update of /cvsroot/tcladdressbook/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23720/Source Modified Files: TclAddressBook.c Log Message: Test if GetMe returns NULL Index: TclAddressBook.c =================================================================== RCS file: /cvsroot/tcladdressbook/Source/TclAddressBook.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- TclAddressBook.c 2 Aug 2004 07:37:19 -0000 1.34 +++ TclAddressBook.c 2 Aug 2004 22:49:38 -0000 1.35 @@ -725,6 +725,7 @@ Tcl_Obj *resultPtr) /* Pointer to store the result. */ { ABAddressBookRef ab; + ABPersonRef myRecord; static CONST char *getmeSwitches[] = { "-id", (char *) NULL @@ -740,23 +741,28 @@ // Get the address book ab = ABGetSharedAddressBook(); - if (objc == 3) { - char theUID[256]; - CFStringRef uniqueId; - int index; - - if (Tcl_GetIndexFromObj(interp, objv[2], getmeSwitches, "option", 0, &index) != TCL_OK) { - return TCL_ERROR; - } - uniqueId = ABRecordCopyUniqueId(ABGetMe(ab)); - CFStringGetCString(uniqueId, theUID, sizeof(theUID), NULL); - CFRelease(uniqueId); - Tcl_SetObjResult(interp, Tcl_NewStringObj(theUID, strlen(theUID))); - } else { - // Store the record's data in the result object - TclAB_GetAllValues(interp, ab, ABGetMe(ab), rec_person); - } + myRecord = ABGetMe(ab); + if (myRecord) { + CFRetain(myRecord); + if (objc == 3) { + char theUID[256]; + CFStringRef uniqueId; + int index; + + if (Tcl_GetIndexFromObj(interp, objv[2], getmeSwitches, "option", 0, &index) != TCL_OK) { + return TCL_ERROR; + } + uniqueId = ABRecordCopyUniqueId(myRecord); + CFStringGetCString(uniqueId, theUID, sizeof(theUID), NULL); + CFRelease(uniqueId); + Tcl_SetObjResult(interp, Tcl_NewStringObj(theUID, strlen(theUID))); + } else { + // Store the record's data in the result object + TclAB_GetAllValues(interp, ab, myRecord, rec_person); + } + CFRelease(myRecord); + } return TCL_OK; } |