Re: NSTextView retain count and HICocoaView problems

2010-07-15 Thread Tony Romano
The reason dealloc is not being called is because you still have a 
retain count > 0.  In cases like this, personally, I always assume my 
code is at fault.  Once I have exhausted all known techniques trying to 
resolve the discrepancy then I escalate it.


Your best bet is to use Instruments, force the leak, then examine how 
the retains/released paired up.  You'll find it.   Instruments is a very 
nice tool.


-Tony
On 7/15/10 3:30 PM, Ryan Joseph wrote:

On Jul 15, 2010, at 4:25 PM, Kyle Sluder wrote:

   

On Wed, Jul 14, 2010 at 9:39 AM, Ryan Joseph  wrote:
 

1) The retainCount from the newly created NSTextView returns 4 and goes up to 7 
after I call HICocoaViewCreate on the NSTextView instance. I tried calling 
release on the NSTextView and DisposeControl on the HICocoaView but neither 
actually dispose of the instance because dealloc is never invoked. I suspect 
this is because of the retain count being what it is.
   

Do not look at -retainCount. It gives you no useful information. If
you want to make sure you're correctly balancing retains and releases,
use the static analyzer and Instruments.
 

Ok, others said this also so the system must be retaining it elsewhere for 
various reasons. The fact dealloc is never called after DisposeControl is 
confusing though since other NSView's worked just fine...

   
 

2) I have a Carbon event handler for mouse moved events installed on the 
application target which after the NSTextView is created stops working, 
probably because the NSTextView was never really deallocated it's consuming the 
mouse events.
   

That's not an accurate description of how the event dispatch works.
 


The how does it work? My observation is simple: when the NSTextView is created 
and focused the mouse handler does not receive events. After I call 
DisposeControl on the HICocoaView the view is removed (no longer visible) but 
the mouse handler continues to not receive events. They must be connected some 
how.

Regards,
Ryan Joseph
thealchemistguild.org

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/tonyrom%40hotmail.com

This email sent to tony...@hotmail.com


   


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Re: NSTextView retain count and HICocoaView problems

2010-07-15 Thread Ryan Joseph

On Jul 15, 2010, at 4:25 PM, Kyle Sluder wrote:

> On Wed, Jul 14, 2010 at 9:39 AM, Ryan Joseph  
> wrote:
>> 1) The retainCount from the newly created NSTextView returns 4 and goes up 
>> to 7 after I call HICocoaViewCreate on the NSTextView instance. I tried 
>> calling release on the NSTextView and DisposeControl on the HICocoaView but 
>> neither actually dispose of the instance because dealloc is never invoked. I 
>> suspect this is because of the retain count being what it is.
> 
> Do not look at -retainCount. It gives you no useful information. If
> you want to make sure you're correctly balancing retains and releases,
> use the static analyzer and Instruments.

Ok, others said this also so the system must be retaining it elsewhere for 
various reasons. The fact dealloc is never called after DisposeControl is 
confusing though since other NSView's worked just fine...

> 
>> 2) I have a Carbon event handler for mouse moved events installed on the 
>> application target which after the NSTextView is created stops working, 
>> probably because the NSTextView was never really deallocated it's consuming 
>> the mouse events.
> 
> That's not an accurate description of how the event dispatch works.


The how does it work? My observation is simple: when the NSTextView is created 
and focused the mouse handler does not receive events. After I call 
DisposeControl on the HICocoaView the view is removed (no longer visible) but 
the mouse handler continues to not receive events. They must be connected some 
how.

Regards,
Ryan Joseph
thealchemistguild.org

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Re: NSTextView retain count and HICocoaView problems

2010-07-15 Thread Kyle Sluder
On Wed, Jul 14, 2010 at 9:39 AM, Ryan Joseph  wrote:
> 1) The retainCount from the newly created NSTextView returns 4 and goes up to 
> 7 after I call HICocoaViewCreate on the NSTextView instance. I tried calling 
> release on the NSTextView and DisposeControl on the HICocoaView but neither 
> actually dispose of the instance because dealloc is never invoked. I suspect 
> this is because of the retain count being what it is.

Do not look at -retainCount. It gives you no useful information. If
you want to make sure you're correctly balancing retains and releases,
use the static analyzer and Instruments.

> 2) I have a Carbon event handler for mouse moved events installed on the 
> application target which after the NSTextView is created stops working, 
> probably because the NSTextView was never really deallocated it's consuming 
> the mouse events.

That's not an accurate description of how the event dispatch works.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


NSTextView retain count and HICocoaView problems

2010-07-15 Thread Ryan Joseph
I have an NSTextView I am allocating programmatically then inserting into a 
HICocoaView for use in a Carbon app. The problem I'm experiencing has 2 points 
that are probably related.

1) The retainCount from the newly created NSTextView returns 4 and goes up to 7 
after I call HICocoaViewCreate on the NSTextView instance. I tried calling 
release on the NSTextView and DisposeControl on the HICocoaView but neither 
actually dispose of the instance because dealloc is never invoked. I suspect 
this is because of the retain count being what it is.

2) I have a Carbon event handler for mouse moved events installed on the 
application target which after the NSTextView is created stops working, 
probably because the NSTextView was never really deallocated it's consuming the 
mouse events.

Is this a bug in NSTextView or is there some special way I need to dispose of 
the HICocoaView? I did some tests using other Cocoa views like NSScrollView but 
they returned 1 as the retainCount and sure enough calling release would 
deallocate the view. Any ideas? Thanks.

Regards,
Ryan Joseph
thealchemistguild.org

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com