Here’s a code snippet from a timer that I have on a window in my app. The time checks to see if the app is in demo mode and if it is, it is supposed to display a Message Dialog with the time left in the demo. But compiling for Win32 throws a Nil Object Exception:
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //for handling the result
d.icon=MessageDialog.GraphicCaution //display warning icon
d.ActionButton.Caption="OK"
If Not Registered Then
App.DemoMode = App.CheckDemo
If App.DemoMode Then
WallAdd = True
d.Message = App.DemoModeMessage
b = d.ShowModal
Xojo is saying that “b” is Nil. Why? The MessageDialog is not NIL.
I’m somewhat confused. Maybe this is also the same problem I’m having in 64 bit but the framework throws up differently…
When does it say that?
In the sample code, b only appears as something that is assigned to.
If it is nil after that line, the RESULT of d.showmodal is nil.
Is it ALWAYS nil, or nil when the user chooses a particular button?
Has the user managed to click a close gadget on the dialog without actually choosing a button?
(Seem to think I saw a post recently about an inability to stop close gadgets appearing)
[quote=398169:@]Because its a 64bit app and not 32bit?
I sound like a broken record I know, but give it a try?[/quote]
No, this is happening when compiling for 32 bit…It’s when I noticed it. 64 bit didn’t throw the exception but just crashed.
The MessageDialog displays just fine. However, during the time the MessageDialog is open, the MainWindow gets resized by an event from another timer firing. This seems to be what is causing the hiccup. I can step through it in the debugger and see the window is open, I can see the MessageDialog appearing but then I see the window resizing. Then then the framework gets back around to the b = d.ShowModal spot, it throws the error.
Is this something I’m doing wrong? Or should the framework not throw the error like this?
I think its a bug though. It looks like messages are getting to where they shouldn’t be which is probably causing the crash.
I cant cause it to crash in a simple demo but I can get it to resize the modal MessageDialog showing that there’s messages getting to places they shouldn’t be.
Wait for the MessageDialog then move it while the window is resizing and it ends up resizing the MessageDialog to an unusable slither as soon as you release the mouse for the move.
I’m sure you’ve thought about it but I guess the only way around your problem at the moment is to pause the timer as the code is executed that causes the crash and resume it after?
It does not crash - it is an exception. Although there’s lots of other bad things going on with Windows in the Xojo 2018. First this exception shouldn’t happen. Second I’m getting a Picture.Constructor exception. And see my other thread on troubles…