Re: Problems with runModalForWindow, looking for alternatives
Re: Problems with runModalForWindow, looking for alternatives
- Subject: Re: Problems with runModalForWindow, looking for alternatives
- From: Conrad Shultz <email@hidden>
- Date: Tue, 01 Nov 2011 12:33:57 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/1/11 11:41 AM, Vojtěch Meluzín wrote:
> But the retainCount is needed for successful release of the window,
> right? I allocate the window and then deallocate it when I'm
> finished with it. But runModalForWindow increases retainCount to 2,
> so when I release it, it's actually not destroyed and causes a
> crash afterward, because for some crazy reason the OS tries to
> repaint the view in it, despite the window is already closed...
Quoting from the NSObject protocol reference:
- - (NSUInteger)retainCount
...
Important: This method is typically of no value in debugging memory
management issues. Because any number of framework objects may have
retained an object in order to hold references to it, while at the
same time autorelease pools may be holding any number of deferred
releases on an object, it is very unlikely that you can get useful
information from this method.
To understand the fundamental rules of memory management that you must
abide by, read “Memory Management Rules”...
You may have a problem leading to a crash, but examining retainCount
will only confuse matters.
> I'm using my own styles. It may be no according to HI guidelines,
> but to be honest, I don't care. The app/plugin should look the same
> on all platforms.
I disagree vehemently (as I suspect do others on the list), but I
won't dwell on this.
> Yaj, ok, can you explain a little more? I don't know much about
> Objective C, how should the MStringToNSString be implemented to
> create the autoreleased NSString? (sorry for lack of knowledge, but
> I just don't plan any further development in objc, just want the
> small layer...)
I don't really know C++, so there is some generalization here. Since
you are returning a retained NSString, presumably inside your function
are you are doing something like:
return [[NSString alloc] initWithCString:stringFromCPlusPlusMethod
encoding:someEncoding];
To return an autoreleased string, instead use:
return [NSString stringWithCString:stringFromCPlusPlusMethod
encoding:someEncoding];
- --
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFOsEmlaOlrz5+0JdURAvPIAJ0T9zfk1j0pkPAppTeXRTQ6Fo9HWgCfYb9W
AWSjxZKNtvONuqN6vS5YvCQ=
=ILa7
-----END PGP SIGNATURE-----
_______________________________________________
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