What would cause this??

Hey guys,

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)

It simply crashes. It’s like the MessageDialog hasn’t been shown.

But yet the MessageDialog is on the screen waiting for user response.

Because its a 64bit app and not 32bit?

I sound like a broken record I know, but give it a try?

[quote=398169:@JulianS]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.

Well, here’s what’s interesting…

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?

Nice to see its not another 64bit issue.

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.

Give this a try:

https://www.dropbox.com/s/r7435a8099ug0yj/BugMessageDialogDuringResize.xojo_binary_project?dl=1

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?

Solution is to run in Xojo 2017R3.1. That works fine.

The message dialog is not being resized. The window behind it is.

I’m curious… is this actually a crash or is it an exception?

It throws the exception and then you get the message that “This Program Has Stopped Working” once you click Ok on them dialog.

I’ll confirm this again later tonight.

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…

And this does not happen in Xojo 2017r3.

So there are definitely problems with the Xojo Windows framework in Xojo2018. It is definitely NOT useable.

You’ll need to try and isolate and replicate this Jon, I can’t get it to crash or throw an error, but I do see a problem that might be related.

feedback://showreport?report_id=52824