Workaround for crash on quit for fullscreen on the Captain

There is this nice bug that an application crashes when quitting in fullscreen mode on the Captain for Xojo versions lower than 2015r3. For a dot release I can’t bring my app to the latest version. So I thought I’d simply exit fullscreen on quitting:

Function IsFullScreen(w as Window) As Boolean Const NSFullScreenWindowMask = 16384 declare function mStyleMask lib "AppKit" selector "styleMask" ( ref as integer ) as integer Return Bitwise.BitAnd( mstyleMask( w.handle ), NSFullScreenWindowMask ) = NSFullScreenWindowMask End Function

[code]Function Quit() As Boolean

if XojoVersion < 2015.3 and isFullScreen(self) then
dim w as new NSWindowMBS(self)
w.toggleFullScreen
end if

Return True

End Function[/code]

In a project with just this code the app crashes on quit. That’s Xojo 2014r2. I’ve set a breakpoint at the first line of the Quit MenuHandler and the breakpoint isn’t reached.

Any idea for a workaround?

Set the window to visible = false before quit. No crash here.

I’ve taken away the fullscreen option , at least until I start releasing with 64bit.

It makes little difference to the screen real estate.
And in fullscreen mode, even though users did it themselves, Ive had people complain ‘the menus are missing/ hard to access’.

No pleasing everyone… :wink:

Does that mean that my software which is build with Xojo 2015 R1 will crash when it is used in fullscreen mode and then quit on El Captain?

Should I then stop selling the app in the app store to prevent bad votings? What could I do to reapair this behaviour (I have the current Xojo desktop version).

It would appear so.

I can tell you that with thousands of users, many of whom have upgraded to El Capitan, I have only had one report of this to date.
I cannot recreate this on my own El Capitan machine.

The scope of the problem is this, assuming you have used 2015 to build…

people who
-have upgraded to El Capitan
-who use Fullscreen (I personally never do, for example)
-leave the app fullscreen until they quit
-have whatever configuration causes the crash.

I dont think this is a widespread problem, or a large one.

Sadly, it took a different post in this forum to find out that this problem was known, but only to beta testers of Xojo.
In the beta group, having discussed it, I have no doubt that those people assumed it was more widely known.

Michel’s visible=false suggestion seems to be the simple and elegant workaround.

Yes, it’s not affecting many users. But I’d still like to have a workaround.

@Michel: where do you put visible = false? The quit MenuHandler isn’t executed so I can’t put it there.

Grr… Had a typo in the Quit MenuHandler name. Michel’s code works fine.

Please vote for feedback://showreport?report_id=38406. I really need larger fonts for the IDE.

Unfortunately I didn’t know about it until the last Yosemite beta and, as far as I remember, I was the first to create a bug report about it. It either isn’t something many users run into in practice or didn’t cause enough problems for anyone to report a bug.