Re-release that causes the window to numb

I use Xcode 4.2 for writing and Clang 3.0 to create a program that demonstrates a specific failure.

The program has a window, which means that it must be next to the one set to nib to "Release When Closed", so it is overfulfilled for the following purposes. This means that it is a sheet, so it is displayed using beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: Trying to show the window a second or third time should lead to the crash of the application.

I remember that this happened a year ago, while the program received EXC_BAD_ACCESS and ran the debugger at that moment. I also remember how to find the problem in the Tools using the Zombies template.

What I want (this program is part of the presentation to show debugging methods), but this is not what is happening now. Now the program does not crash; The tools show that the retention rate in the window is reduced to 1 time, but not lower, so it is not released.

It would be nice if the problem stopped there; I could just hide and show the sheet one or two more. The problem is that the second time I pick up the sheet (it should be dead, but still have the least-keep-keep-it-alive), it is numb.

By this, I mean that neither the sheet, nor any control in it (it contains a field, text view and two buttons) react to events. The heartbeat does nothing in this; there is an OK button in the window, but when the window is numb, the OK button does not pulsate. Nothing works to reject a sheet.

But the program does not crash. I can still interact with the menu, and the Dock shows that the program is responding. If I try to get out of it, it will beep, as it has a sheet up.

What makes a window go numb, and what can I do with it?

Here the version of the program also detects a problem: https://github.com/boredzo/NumbWindow

+6
source share
1 answer

I do not think you should use -close to make the sheet go away. If you change the line [sheet close]; on [sheet orderOut:self]; Then it will work correctly.

As to why they are different, I do not know. But my experience was to always use -orderOut: to reject sheets and never -close . The documentation supports me on this issue:

Listing 3 Make an end selector

 - (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { [sheet orderOut:self]; } 

TL; DR:

You are using the wrong method to make the panel disappear.

+4
source

Source: https://habr.com/ru/post/899669/


All Articles