How to debug a non-working declare?

Been working a while with the Chilkat lib for IMAP. Since my test application does what I want, today I integrated the code into my mail application. Now one of the declares doesn’t want to work. I can register the lib, logging into an IMAP account also works. But getting the mailboxes simply does nothing:

[code] declare function ListMailboxes lib ImapLibLocation selector “ListMailboxes:wildcardedMailbox:” _
(obj as Ptr, refname as CFStringRef, wildcard as CFStringRef) as Ptr

dim p as Ptr = ListMailboxes(self, “”, “*”)
if p <> nil then
dim theMailboxes as new MailboxesCko(p, False)
MailboxesOriginal = theMailboxes.getMailboxes
MailboxFlags = theMailboxes.getFlags
end[/code]

In the test app p is not nil. In the main app p is nil. The code uses MacOSlib. The super of the class of the code is NSObject.

How do I find out why the declare isn’t working? I can’t see a difference in the execution compared to the test app.

Mac OS 10.10. Xojo 2015r2.

Objective-C function calls return no error if object is nil.

Also why do you pass self here? Shouldn’t you pass a handle or object pointer?

self is used here because the super of the class is NSObject. At least that is what Thomas Tempelmann taught me about declares.

so he probably overloaded it with Operator_Convert?

Anyway, if this would return nil, the call will do nothing.

Is self really an instance of the same class as in your test application?

@Eli: yes, the codes lives in the same class in both apps. Actually, the class is the same external item.

But I had another idea: in the test app the code is executed directly. In the main app I have the usual mess of threads and timers. I dimly remember having problems with code in threads before. Will do some testing tomorrow.

The CkoImap class has a LastErrorText property (plus a LastResponse and a LastResponseCode). These will help you debugging.

So you could try this:

dim p as Ptr = ListMailboxes(self, "", "*") if p is nil then MsgBox self.LastErrorText else dim theMailboxes as new MailboxesCko(p, False) MailboxesOriginal = theMailboxes.getMailboxes MailboxFlags = theMailboxes.getFlags end