Re: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-15 Thread Dev
I just change my NSWindow from NSBackingStoreBuffered to a NonRetain one and my
application do not crash anymore.

Unfortunatly, as expected, my window is clipping  how ever i just
realize that the crash might have a relation with the NSWindow double
buffer mechanism.

So my solution to the problem was instead of replacing the NSImage
using setImage,
i grab directly my NSImage from the View, then pick the representation
and write
directly into it.

It is as a matter of fact, a way better effective way of doing what i
was doing and
it's avoiding all my release problems.

thx
-- 
I.

On Sat, Mar 14, 2009 at 12:37 PM, Volker in Lists
volker_li...@ecoobs.de wrote:
 Hi,

 retainCount is not in anyway useful when debugging - I had many cases of rc
 5 with the object being gone the next instance. your error sounds like you
 loose the image at some point in time. retain it and use Instruments to see
 if you leak or over alloc.

 Volker

 Am 14.03.2009 um 01:23 schrieb Dev:

 On Wed, Mar 11, 2009 at 9:33 AM, Scott Ribe scott_r...@killerbytes.com
 wrote:

 Does your setImage method retain the image?

 The object ExternalView is a NSImageView so the setImage is the one of
 NSImageView.
 The doc says nothing about it, but i added some debug log like this :

                      NSLog(@BEFORE : %d, [NewDisplayImage retainCount]);
                      [CameraView setImage:NewDisplayImage];
                      NSLog(@AFTER : %d, [NewDisplayImage retainCount]);

 2009-03-13 17:17:35.105 xxx[2281:e503] BEFORE : 1
 2009-03-13 17:17:35.106 xxx[2281:e503] AFTER : 3

 So i guess the image have been retained 2 times 
 --
 I.
 ___

 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/volker_lists%40ecoobs.de

 This email sent to volker_li...@ecoobs.de


___

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: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-15 Thread Dev
For people that might have the same issue :

=NEW CODE=

NSImage *NewDisplayImage = [ExternalView image];
if (NewDisplayImage == nil)
{

NSBitmapImageRep *rawPic = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:thisFrame.width pixelsHigh:thisFrame.height
bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:0
bitsPerPixel:0] autorelease];

unsigned char *DestinationRawData = [rawPic bitmapData];
memcpy(DestinationRawData, CurrentFrame, SzCurrentFrame);
[self RGB2BGR:DestinationRawData Sz:SzCurrentFrame];

NewDisplayImage = [[[NSImage alloc] initWithSize:thisFrame] 
autorelease];
[NewDisplayImage addRepresentation:rawPic];
[ExternalView setImage:NewDisplayImage];
}
else
{
NSArray *representations = [NewDisplayImage representations];
NSBitmapImageRep *rawPic = [representations objectAtIndex:0];
if (rawPic != nil)
{
unsigned char *DestinationRawData = [rawPic bitmapData];
memcpy(DestinationRawData, CurrentFrame, SzCurrentFrame);
[self RGB2BGR:DestinationRawData SzCurrentFrame];   
[CameraView setNeedsDisplay];
}
}



=CODE=



On Sun, Mar 15, 2009 at 10:08 AM, Dev d...@i-bch.com wrote:
 I just change my NSWindow from NSBackingStoreBuffered to a NonRetain one and 
 my
 application do not crash anymore.

 Unfortunatly, as expected, my window is clipping  how ever i just
 realize that the crash might have a relation with the NSWindow double
 buffer mechanism.

 So my solution to the problem was instead of replacing the NSImage
 using setImage,
 i grab directly my NSImage from the View, then pick the representation
 and write
 directly into it.

 It is as a matter of fact, a way better effective way of doing what i
 was doing and
 it's avoiding all my release problems.

 thx
 --
 I.

 On Sat, Mar 14, 2009 at 12:37 PM, Volker in Lists
 volker_li...@ecoobs.de wrote:
 Hi,

 retainCount is not in anyway useful when debugging - I had many cases of rc
 5 with the object being gone the next instance. your error sounds like you
 loose the image at some point in time. retain it and use Instruments to see
 if you leak or over alloc.

 Volker

 Am 14.03.2009 um 01:23 schrieb Dev:

 On Wed, Mar 11, 2009 at 9:33 AM, Scott Ribe scott_r...@killerbytes.com
 wrote:

 Does your setImage method retain the image?

 The object ExternalView is a NSImageView so the setImage is the one of
 NSImageView.
 The doc says nothing about it, but i added some debug log like this :

                      NSLog(@BEFORE : %d, [NewDisplayImage retainCount]);
                      [CameraView setImage:NewDisplayImage];
                      NSLog(@AFTER : %d, [NewDisplayImage retainCount]);

 2009-03-13 17:17:35.105 xxx[2281:e503] BEFORE : 1
 2009-03-13 17:17:35.106 xxx[2281:e503] AFTER : 3

 So i guess the image have been retained 2 times 
 --
 I.
 ___

 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/volker_lists%40ecoobs.de

 This email sent to volker_li...@ecoobs.de



___

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: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-14 Thread Volker in Lists

Hi,

retainCount is not in anyway useful when debugging - I had many cases  
of rc  5 with the object being gone the next instance. your error  
sounds like you loose the image at some point in time. retain it and  
use Instruments to see if you leak or over alloc.


Volker

Am 14.03.2009 um 01:23 schrieb Dev:

On Wed, Mar 11, 2009 at 9:33 AM, Scott Ribe scott_r...@killerbytes.com 
 wrote:

Does your setImage method retain the image?


The object ExternalView is a NSImageView so the setImage is the one of
NSImageView.
The doc says nothing about it, but i added some debug log like this :

  NSLog(@BEFORE : %d, [NewDisplayImage  
retainCount]);

  [CameraView setImage:NewDisplayImage];
  NSLog(@AFTER : %d, [NewDisplayImage  
retainCount]);


2009-03-13 17:17:35.105 xxx[2281:e503] BEFORE : 1
2009-03-13 17:17:35.106 xxx[2281:e503] AFTER : 3

So i guess the image have been retained 2 times 
--
I.
___

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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de


___

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: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-13 Thread Dev
On Wed, Mar 11, 2009 at 9:33 AM, Scott Ribe scott_r...@killerbytes.com wrote:
 Does your setImage method retain the image?

The object ExternalView is a NSImageView so the setImage is the one of
NSImageView.
The doc says nothing about it, but i added some debug log like this :

   NSLog(@BEFORE : %d, [NewDisplayImage retainCount]);
   [CameraView setImage:NewDisplayImage];
   NSLog(@AFTER : %d, [NewDisplayImage retainCount]);

2009-03-13 17:17:35.105 xxx[2281:e503] BEFORE : 1
2009-03-13 17:17:35.106 xxx[2281:e503] AFTER : 3

So i guess the image have been retained 2 times 
--
I.
___

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: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-11 Thread Scott Ribe
Does your setImage method retain the image?

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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


EXC_BAD_ACCESS on NSImageView::setImage

2009-03-10 Thread Dev
I have a window that contains a NSImageView that displays pictures.

here is the code :
=CODE=
NSBitmapImageRep *rawPic = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:thisFrame.width pixelsHigh:thisFrame.height
bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:0
bitsPerPixel:0] autorelease];
unsigned char *DestinationRawData = [rawPic bitmapData];
memcpy(DestinationRawData, CurrentFrame, SzCurrentFrame);
[self RGB2BGR:DestinationRawData Sz:SzCurrentFrame];

NSImage *NewDisplayImage = [[[NSImage alloc] initWithSize:thisFrame]
autorelease];
[NewDisplayImage addRepresentation:rawPic];
[ExternalView setImage:NewDisplayImage];
=CODE=

The ExternalView display correctly what i want for a while, no memory leak
appears but
after few seconds the program gives me a bad EXC_BAD_ACCESS.

After commenting the last line (setImage) there is absolutely no crash.
Thinking of a side-effect i checked all sizes and everything seams to
fit.

I also tried to remove the autorelease and replace them by some release
after
the set image but nothing seams to work.

Can anybody see something wrong ?

Is there any other way to do what i m doing ?

Thanks for the peolple that will help me.
Sincerely,
-- 
I.
___

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