I’m seeing some strange crashes from some customers for what appears to be an NOE related to an SMTP socket, but there is no SMTP socket relevant to the code executing where the error occurs.
I think I may have found this but I’m some what confused… I was able to make the error happen on my machine.
I have a Window that shows up the very first time the user starts the app where they enter their name and email. That then e-mails me from an SMTPSocket. I don’t allow the window to close until that SMTPSocket’s work is complete. But it appears something is still possibly happening with this socket? That’s the only thing I can think of…But I don’t use an AddHandler directive on it…
OK. So I figured out what was causing this but I’m not sure I completely understand why. Something has changed with the SMTPSocket in the framework. Thinking I should file a bug report.
So I have the Socket sending an e-mail. In the MailSent Event for the socket, I close the Window. The window gets destroyed but the socket does not. The socket is still existing. I can see it in the debugger when the program breaks for the exception. The exception is happening in the Xojo framework. There is a WeakRef for the ownerWindow of the socket - it’s NIL. But the socket is still there.
I’ve just had a very similar problem. Mine was that I was closing the window in the changed event of a listbox and that caused a framework assertion which crashed the application. The workaround is to use xojo.core.timer.calllater(0, addressof ).
Does the SMTPSocket (subclass) own the window being closed in the MailSent event and/or is the SMTPSocket a property of this window?
Do you have a circular reference ownerWindow ↔ SMTPSocket?
[quote=268431:@Eli Ott]Does the SMTPSocket (subclass) own the window being closed in the MailSent event and/or is the SMTPSocket a property of this window?
Do you have a circular reference ownerWindow <-> SMTPSocket?[/quote]
The SMTP socket is not subclassed. It’s just a standard SMTPSocket dropped onto the window. So no, there’s no circular references unless the Xojo framework is creating them.
[quote=268404:@Wayne Golding]I’ve just had a very similar problem. Mine was that I was closing the window in the changed event of a listbox and that caused a framework assertion which crashed the application. The workaround is to use xojo.core.timer.calllater(0, addressof ).
It must be a similar issue. There’s no reason why you should not be able to close a window from the event in a control. Having to use a timer is a hack, frankly.
I already had a timer in there that I was using to close the window in the event of an SMTPSocket error. So I’m just using that timer after the mail sent event as well.
The user can’t close the window. Unless some socket event fires after mailsent then no.
See my example in feedback. Stephane quickly closed it as not reproducible but I beg to differ. I know he didn’t even try it out becuase the app sends me an email!
[quote]
See my example in feedback. Stephane quickly closed it as not reproducible but I beg to differ. I know he didn’t even try it out becuase the app sends me an email![/quote]
I suspect he changed the code to email to himself.