Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

snakebytes

macrumors newbie
Original poster
Nov 16, 2009
5
0
I've had a custom photo app built and am now trying to fix an error/bug. In 2.2 the app functions perfectly, but in 3.1 the application crashes when attempting to take a picture.

In 2.2, when I hit the shutter release button, after a moment an image is saved to the photo library. In 3.1, when I hit the shutter release button the app closes.

I hope someone can tell me if there's something obvious in the code..

Thanks, Chris

The following is the code (which xcode is showing as error)

Code:
- (UIImage*)correctImageOrientation:(CGImageRef)imag e {

CGImageRef img = UIGetScreenImage();
UIImage* scImage=[UIImage imageWithCGImage:img];
CFRelease(img);
return scImage;
//UIImage imageWithCGImage:UIGetScreenImage();
}


- (BOOL)grabPictureFromImageView:(UIView*)view {

CGImageRef img = (CGImageRef)[view imageRef];
if (img)
{
// Taken image is in UIImageOrientationRight orientation

UIImage *photo = [self correctImageOrientation:img]; // get the captuered image in the photo with correct orientation
//UIImageWriteToSavedPhotosAlbum(photo, nil, nil, nil);

UIImageWriteToSavedPhotosAlbum(photo, self, @selector(imageSavedToPhotosAlbum:didFinishSavingW ithError:contextInfo:), nil); //save the image in the album
[imageCopy release]; imageCopy = nil;
return YES;
}

return NO;
}
 
My guess is UIGetScreenImage() returns an image that you should not release. That is usually how Get functions work, so try removing the CFRelease(img); line.
 
I'll try it tonight. Thanks.

My guess is UIGetScreenImage() returns an image that you should not release. That is usually how Get functions work, so try removing the CFRelease(img); line.

Thanks for your advice Kainjow, I'll give it a shot!
Chris.
 
Didn't work :(

My guess is UIGetScreenImage() returns an image that you should not release. That is usually how Get functions work, so try removing the CFRelease(img); line.

Hey, I tried that. It didn't work! any other suggestions?

Thanks,
Chris
 
What line does it crash on? What kind of crash is it? What text is shown in the debugger console when it crashes?
 
What line does it crash on? What kind of crash is it? What text is shown in the debugger console when it crashes?


I am not exactly sure what line it crashes on. I get a warning when compiling the code "Implicit declaration of function "UIGetScreenImage" as well as "Initialization makes pointer from integer without a cast" on the line " CGImageRef img= UIGetScreenImage();"

And "UIView" mat no respond to "-imageRef" on the line "CGImageRef img = (CGImageRef)[view imageRef];"

The crash when debugging is a SIGABRT signal sent. Basically, the application entirely quits.

This is the crash log :

--------------
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0

Thread 0 Crashed:
0 libSystem.B.dylib 0x31a279ac 0x319a9000 + 518572
1 libSystem.B.dylib 0x31a2799c 0x319a9000 + 518556
2 libSystem.B.dylib 0x31a2798e 0x319a9000 + 518542
3 libSystem.B.dylib 0x31a3c63a 0x319a9000 + 603706
4 libstdc++.6.dylib 0x3361d3b0 0x335d8000 + 283568
5 libobjc.A.dylib 0x32401858 0x323fc000 + 22616
6 libstdc++.6.dylib 0x3361b776 0x335d8000 + 276342
7 libstdc++.6.dylib 0x3361b7ca 0x335d8000 + 276426
8 libstdc++.6.dylib 0x3361b896 0x335d8000 + 276630
9 libobjc.A.dylib 0x32400714 0x323fc000 + 18196
10 CoreFoundation 0x32537b86 0x32511000 + 158598
11 CoreFoundation 0x32537b24 0x32511000 + 158500
12 Foundation 0x3140d8cc 0x313ed000 + 133324
13 Foundation 0x31432ca8 0x313ed000 + 285864
14 Turbo 0x00005ff0 -[RootViewController getCamShutButton] (RootViewController.m:162)
...
...
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x383c43cc
r4: 0x00000006 r5: 0x3361b30d r6: 0x001509dc r7: 0x2fffea00
r8: 0x2fffe9ec r9: 0x00000065 r10: 0x00000001 r11: 0x001503b0
ip: 0x00000025 sp: 0x2fffea00 lr: 0x31a279a3 pc: 0x31a279ac
cpsr: 0x000f0010
-------------


Thanks so much.!

Chris
 
Couple things.

This code makes me shudder.

Those two lines that throw compiler errors are because those methods are either undocumented or non-existent. Apparently UIGetScreenImage() does exists but isn't documented. If you want to continue using it you should add this to the top of the source file.

Code:
extern "C" CGImageRef UIGetScreenImage();

It is possible that UIImageView has a private method called imageRef and it's possible that the view passed to your grabPictureFromImageView is really a UIImageView and not a UIView.

I notice that the method from your code shown in the stack trace is getCamShutButton, which isn't one of the methods whose source you show.

Unless you can step through the source code and into the getCamShutButton to figure out where and why it's crashing I'm not sure what help I can be.

If the code you show is indicative of the quality of the rest of the code in your project this won't be the only bug. You probably need to find a real developer to look at the code and fix it.
 
Would you give me a quote?

Couple things.

This code makes me shudder.

Those two lines that throw compiler errors are because those methods are either undocumented or non-existent. Apparently UIGetScreenImage() does exists but isn't documented. If you want to continue using it you should add this to the top of the source file.

Code:
extern "C" CGImageRef UIGetScreenImage();

It is possible that UIImageView has a private method called imageRef and it's possible that the view passed to your grabPictureFromImageView is really a UIImageView and not a UIView.

I notice that the method from your code shown in the stack trace is getCamShutButton, which isn't one of the methods whose source you show.

Unless you can step through the source code and into the getCamShutButton to figure out where and why it's crashing I'm not sure what help I can be.

If the code you show is indicative of the quality of the rest of the code in your project this won't be the only bug. You probably need to find a real developer to look at the code and fix it.


Would you be interested in taking a look at the code and giving me a quote? The thing is I've spent a whole lot already and am left with an app which doesn't function. I know it's probably better to go through and clean it all up, but I'd prefer if you'd just fix the problem and leave the mess. :)

It does work flawlessly on 2.2, it's only in 3.1 that it crashes.

you can email me at chris "at" snakebytestudio.com

Thanks so much,

Chris
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.