Shikhar13 / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

iOS port crashes when using Storage.getInstance().clearStorage() #188

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have some data stored using the cn1 Storage API.
2. Then call clearStorage() to clear the storage.
3.

What is the expected output? What do you see instead?
The storage data should get deleted.

What version of the product are you using? On what operating system?
Codename plugin ver 1.0.4 and using on Mac OS running in the iPhone simulator. 
The behaviour is re-producible on the actual iPhone device also.

Please provide any additional information below.
Error Debug output on the console is printed below:
2012-05-07 13:52:30.587 S2PayApp[57458:1d503] -[NSFileManager 
contentsOfDirectoryAtPath:]: unrecognized selector sent to instance 0xb5ceea0
2012-05-07 13:52:30.599 S2PayApp[57458:1d503] *** Terminating app due to 
uncaught exception 'NSInvalidArgumentException', reason: '-[NSFileManager 
contentsOfDirectoryAtPath:]: unrecognized selector sent to instance 0xb5ceea0'
*** First throw call stack:
(0x421f022 0x43b0cd6 0x4220cbd 0x4185ed0 0x4185cb2 0x10f1e6f 0x64fbee 0x55bba6 
0x6ab075 0x377b51 0x376c13 0xef7860 0xa1b600 0xf8057e 0xf7f21f 0xc3428d 
0xc3a0c0 0xc3a162 0xa0771a 0x69792b 0x8ffce7 0x8f1f11 0x8f03a6 0x456e4c 
0x8d32b9 0x10de98e 0x111d019 0x1118fba 0x111cb09 0x909c8ed9 0x909cc6de)
terminate called throwing an exception(lldb)

Also the code is showing SIGABRT at the following function in iOS source code:

JAVA_INT 
com_codename1_impl_ios_IOSNative_fileCountInDir___java_lang_String(JAVA_OBJECT 
dir) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSFileManager* fm = [[NSFileManager alloc] init];
    const char* chrs = stringToUTF8(dir);
    NSString* ns = [NSString stringWithUTF8String:chrs];
    NSArray* nsArr = [fm contentsOfDirectoryAtPath:ns]; // <-------- Error on this line 
    int i = nsArr.count;
    [fm release];
    [pool release];
    return i;   
}

Original issue reported on code.google.com by nir...@nvsoft.com on 7 May 2012 at 8:45

GoogleCodeExporter commented 9 years ago
Thanks. I updated the server with a new version it should be working now.

Original comment by shai.almog on 7 May 2012 at 11:31

GoogleCodeExporter commented 9 years ago
Hi Shai,

I tried again after re-buidling the app. However it still crashes when I try to 
clear data using clearStorage(). Here's the debug output:

2012-05-07 17:31:55.848 S2PayApp[77851:1d503] -[NSFileManager 
contentsOfDirectoryAtPath:]: unrecognized selector sent to instance 0xb4ba0b0
2012-05-07 17:31:55.850 S2PayApp[77851:1d503] *** Terminating app due to 
uncaught exception 'NSInvalidArgumentException', reason: '-[NSFileManager 
contentsOfDirectoryAtPath:]: unrecognized selector sent to instance 0xb4ba0b0'
*** First throw call stack:
(0x4241022 0x43d2cd6 0x4242cbd 0x41a7ed0 0x41a7cb2 0x10f53ff 0x6526ae 0x55e6b6 
0x6ae8d5 0x378d01 0x377dc3 0xf01738 0xa1f140 0xf8bcbe 0xf8a95f 0xc3b1fd 
0xc4102b 0xc410d2 0xa0b25a 0x69b0eb 0x903947 0x8f5b71 0x8f4006 0x457ffc 
0x8d6ed9 0x10ea8ee 0x1129249 0x11251ea 0x1128d39 0x909c8ed9 0x909cc6de)
terminate called throwing an exception

Thanks,
Nirmal

Original comment by nir...@nvsoft.com on 7 May 2012 at 12:05

GoogleCodeExporter commented 9 years ago
Did you download the sources? 
I've changed the method call signature to [fm contentsOfDirectoryAtPath:ns 
error:nil];

If it doesn't include the error argument that might be the problem. I just 
updated the server again and verified that this argument made it into the build 
distribution. 

Original comment by shai.almog on 7 May 2012 at 12:20

GoogleCodeExporter commented 9 years ago
Yes, I downloaded the sources. The source file contains this:

 NSArray* nsArr = [fm contentsOfDirectoryAtPath:ns];

So let me re-try one more time and see what the source contains.

Original comment by nir...@nvsoft.com on 7 May 2012 at 12:30

GoogleCodeExporter commented 9 years ago
Thanks Shai, it works now.

Original comment by nir...@nvsoft.com on 7 May 2012 at 1:22