Order out NSWindow.

Discussion in 'Mac Programming' started by larswik, Aug 6, 2011.

  1. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    I have a couple of additional windows that open for my app. I have buttons that close them just fine. The other day I used the red button on the top left to close the window and it crashed my program.

    I am guessing I need to code an order out for that button? I don't even know where it is located if I do need to write code for it?

    Thanks,

    -Lars
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    1. What does the crash log show was executing at the time of the crash?


    2. Run your program under Instruments.app, with zombies enabled (google it). Do the action that causes the crash (click the red button). If you see a notice that you're using a deallocated object (i.e. a zombie), then find and fix your memory management bug.

    I have mentioned Instruments and zombies before. It's a pretty normal part of debugging. If you're not doing it, and you have no strategy for debugging unexpected crashes, you should probably spend a little time writing down some specific steps to take when things crash. When you can't remember the systematic steps to take, refer to the written procedure. One of those steps should be "Post the crash log when asking on MacRumors".
     
  3. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    Thanks Chown33, I will be home tonight and look at it. I too the program on a jump drive to our party that we had and showed it and saw the crash on his computer.

    I will crash the program and get the information on the report. But as far as I have seen those buttons manage themselves unless I want to override them.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    You may have to get the crash log from the other computer. It's possible the problem only appears when running in that computer's environment. You may not be able to duplicate the problem. This would not be unusual. You should still try to duplicate the problem, just warning that it may not succeed.
     
  5. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #5
    Here is the crash log from the other computer.I tested it a little more and I can have 3 NSWindows open and they all crash the program. But I don't think it is the window close button anymore. They close fine but when I click on the NSButton to bring them up a second time, that is when they crash. The problem must be in my code.

    Here is the log
    I need to learn how to read these logs.
     
  6. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    Well, it crashed in Thread 0. Some code handles a mousedown event, then an action is sent, at last the NSApplication method sendAction:to:from: is called, that tries to send a message, and the attempt to send the message crashes.

    Most likely sending a message to an object that doesn't exist anymore. I bet closing the window released it, and then you try to make a released window visible again. Have look in Interface Builder at the properties of the windows that you are closing if there is anything related to releasing a window when it is closed.
     
  7. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #7
    Or run under Instruments with zombies enabled, and it will tell about every attempt to message an object that no longer exists.
     
  8. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #8
    Thanks guys, I had time to look at it today. I did the quick solve in IB and unchecked the 3 boxes so the user can't select them. When the additional NSWindow opens up and they press the NSButton to 'orderout' that window it works fine.

    I did try a test thought and created an tried to have the first line of code in the NSButton and orderOut:self before I used themakeKeyAndOrderFront: to try to close just in case. It did not work.

    With regards to the crash report. I am guessing this is the important part
    Is this part where it errored
    I can follow the list and see what is happening but what do the +numbers mean?
     
  9. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #9
    It's the number of bytes into the method/function.
     
  10. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #10
    No, it crashed in "objc_msgSend" which was called from "-[NSApplication sendAction:to:from:]". You can Google for "objc_msgSend", but it is the code that sends instance messages.
     
  11. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #11
    I see, thanks.

    I think I know what happened. I have 3 windows in my xib file that are just hidden and I use the makeKeyAndOrderFront: When an NSButton is pressed. If I close that second window using the red button it really closes it instead of hiding it which I do with another NSButton to Orderout.

    So when I click on the NSButton to makeKeyAndOrderFront: again, there is nothing to bring up.
     

Share This Page