• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
premature dealloc of the datasource of a NSTableView crashes my application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

premature dealloc of the datasource of a NSTableView crashes my application


  • Subject: premature dealloc of the datasource of a NSTableView crashes my application
  • From: "Dr. Rolf Jansen" <email@hidden>
  • Date: Sat, 4 Oct 2008 17:01:34 -0300

Mac OS X 10.5.5, Xcode 3.1.1, PowerBook G4.

I have developed a Document Based Cocoa application, and the main document window contains a simple datasource based NSTableView. After I recently re-built everything with Xcode 3.1.1, my application crashes when I close any document window. Everything document, datasource, tableview are instantiated in the NIB file that is owned by the document object.

It took me some time to find out what is going on, anyway I am quite sure that the reason for the crash is a premature dealloc of the datasource of the NSTableView, in the course of closing the document window. In order to prevent my application from crashing, I overwrote - [NSObject dealloc] of the datasource to the following:

- (void)dealloc
{
   return;
   [super dealloc]; // this prevents the warning that
}                   // [super dealloc] is not called.


Unbelievable, but true - I checked this several times, that this prevents my application from crashing.



Questions:

- what determines the order of dealloc of
  NIB instances once a document closes?

- is it possible that this order changed
  somehow between Xcode 3.1.1 and Xcode 3.1

- can I set the dealloc sequence somehow myself,
  e.g. by dragging the objects of the NIB
  into a certain order?


Probably not exactly related to this, I experience another issue of premature dealloc, that also occurred only recently, without changing any code of my application.


The document has one independent main document window and it can open many dependent windows. When closing the main window, then the document and with that the dependent windows are forced to close too (- [MainDocWindowController setShouldCloseDocument:YES]). All of a sudden, my application deallocs the document object and its instances first, and then the dependent window objects. Also because of this my application started to crash, because for cleaning up, the dependent window objects are still needing to access some resources of the document object, that unfortunately has been dealloced prematurely.

Any ideas, on how I can enforce the previous more logical dealloc sequence - the dependent window objects first, then the main window object, and finally the document object itself?

Many thanks for any response.

Best regards

Rolf Jansen

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: premature dealloc of the datasource of a NSTableView crashes my application
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Best way to implement a "dynamic" panel
  • Next by Date: Memory Leak in XIB file?
  • Previous by thread: Re: Best way to implement a "dynamic" panel
  • Next by thread: Re: premature dealloc of the datasource of a NSTableView crashes my application
  • Index(es):
    • Date
    • Thread