On Nov 1, 2011, at 8:43 AM, Vojtěch Meluzín wrote:

> On the other hand now runModalForWindow increases retainCount! Why is that? 
> It makes no sense to me.

It’s probably being retained and then autoreleased by AppKit. Don’t pay any 
attention to retainCount, it’s generally not useful for detecting memory issues.

However, note that you called -alloc to create the NSWindow, so by the memory 
guidelines you are responsible for releasing it when you’re through with it.

> Also the window still appears in background (code below) and cursor cannot be 
> changed.

What app is this in? Is it a Carbon app? I’ve never done Cocoa-in-Carbon 
embedding but I think there may be some special considerations involved.

>             NSUInteger style = NSBorderlessWindowMask;

Borderless windows can’t get keyboard focus by default. If you want that you’ll 
have to subclass NSWindow and override -canBecomeKey.

Also, running a borderless window as modal is kind of weird and probably 
contrary to the HI Guidelines. Is there a good reason this needs to not have a 
title bar?

>             NSString *titlens = MStringToNSString(caption);
>             [desc->Window setTitle: titlens ];
>             [titlens release];

This seems sort of weird — your MStringToNSString doesn’t return an 
autoreleased NSString? That’s against refcounting conventions and rather 
error-prone.

>             
>             [desc->Window setContentView: desc->View];

I don’t see any code to release desc->View. If you’re not already releasing it 
after the code you showed, this line might be a good place to add the -release 
call, since the view is now retained by the window.

> // Activate the process...
>              ProcessSerialNumber ourPsn = {0, kCurrentProcess};
>             //OSStatus status = 
>             SetFrontProcess(&ourPsn);

This is unnecessary if you’re already calling -activateIgnoringOtherApps:, 
which does the same thing.

—Jens_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to