Created
October 6, 2012 21:02
-
-
Save shannah/3846116 to your computer and use it in GitHub Desktop.
JNI method that crashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JNIEXPORT jstring JNICALL Java_ca_weblite_mactools_Sandbox_saveDialog | |
(JNIEnv *env, jobject jthis, jstring title, jstring extension){ | |
JNF_COCOA_ENTER(env); | |
jstring path; | |
//@autoreleasepool { | |
NSString *cocoaExtension = JNFJavaToNSString(env, extension); | |
NSSavePanel *panel = [NSSavePanel savePanel]; | |
NSArray *types = [NSArray arrayWithObjects: cocoaExtension,nil]; | |
[panel setAllowedFileTypes: types]; | |
[panel setCanSelectHiddenExtension:TRUE]; | |
[panel setExtensionHidden:TRUE]; | |
[panel setTitle: JNFJavaToNSString(env, title)]; | |
if ( [panel runModal] == NSFileHandlingPanelOKButton ){ | |
NSURL * out = [[panel URL] filePathURL]; | |
NSString *outStr = [out path]; | |
const char *cString = [outStr UTF8String]; | |
path = (*env)->NewStringUTF(env, cString); | |
} else { | |
path = NULL; | |
} | |
//} | |
return path; | |
JNF_COCOA_EXIT(env); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JNIEXPORT jstring JNICALL Java_ca_weblite_mactools_Sandbox_saveDialog | |
(JNIEnv *env, jobject jthis, jstring title, jstring extension){ | |
//JNF_COCOA_ENTER(env); | |
jstring path; | |
@autoreleasepool { | |
NSString *cocoaExtension = JNFJavaToNSString(env, extension); | |
NSSavePanel *panel = [NSSavePanel savePanel]; | |
NSArray *types = [NSArray arrayWithObjects: cocoaExtension,nil]; | |
[panel setAllowedFileTypes: types]; | |
[panel setCanSelectHiddenExtension:TRUE]; | |
[panel setExtensionHidden:TRUE]; | |
[panel setTitle: JNFJavaToNSString(env, title)]; | |
if ( [panel runModal] == NSFileHandlingPanelOKButton ){ | |
NSURL * out = [[panel URL] filePathURL]; | |
NSString *outStr = [out path]; | |
const char *cString = [outStr UTF8String]; | |
path = (*env)->NewStringUTF(env, cString); | |
} else { | |
path = NULL; | |
} | |
} | |
return path; | |
//JNF_COCOA_EXIT(env); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment