Hi guys, I'm losing my mind over this, I hope someone can help me.
Basically I have this data source class that inherits from a Sqlite class that I created which has some generic select/insert methods. I call this data source class' insert method on the save button of my form. After this, the form closes and shows the previous one and obviously it releases my data source variable on the closing form. At this point the program crashes and floods the console with messages such as:
I do have the standard autorelease pool on my main file, so this makes absoultely no sense to me. Now, after a lot of commenting and un-commenting code, I've isolated the problem specifically to the insert method on the data source's sqlite superclass. If I don't call this method the data source class releases correctly. This is the code of the insert method:
Note that this code works and inserts rows correctly, although it can probably be improved since this is my first sqlite attempt on the iphone/objective c. I've checked all related code and everything I create is being released properly. I don't think I'm over-releasing either. If I don't call[dataSourceObject release]; the program works fine, but I think I should release it since I created it. So I guess that would cause leaks anyway.
What am I doing wrong, any ideas? Thanks in advance.
Basically I have this data source class that inherits from a Sqlite class that I created which has some generic select/insert methods. I call this data source class' insert method on the save button of my form. After this, the form closes and shows the previous one and obviously it releases my data source variable on the closing form. At this point the program crashes and floods the console with messages such as:
Code:
2009-07-12 13:50:56.589 CodenameChimp[776:bc03] *** _NSAutoreleaseNoPool(): Object 0x63d910 of class UIDeviceRGBColor autoreleased with no pool in place - just leaking
Stack: (0x91f4fd74 0x91e7cdfc 0xc2d0 0xc3ec 0x91e82d70 0x939770c8)
I do have the standard autorelease pool on my main file, so this makes absoultely no sense to me. Now, after a lot of commenting and un-commenting code, I've isolated the problem specifically to the insert method on the data source's sqlite superclass. If I don't call this method the data source class releases correctly. This is the code of the insert method:
Code:
- (NSNumber *)insertIntoDatabase:(const char *)sqlStatement withParameters:(NSArray *)params
{
NSNumber *primaryKey = [NSNumber numberWithInt:-1];
sqlite3 *database;
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
for (int i = 0; i < [params count]; i++)
{
NSString *paramValue = (NSString *)[params objectAtIndex:i];
sqlite3_bind_text(compiledStatement, i + 1, [paramValue UTF8String], -1, SQLITE_TRANSIENT);
}
int success = sqlite3_step(compiledStatement);
if (success != SQLITE_ERROR)
primaryKey = [NSNumber numberWithInt:sqlite3_last_insert_rowid(database)];
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return primaryKey;
}
Note that this code works and inserts rows correctly, although it can probably be improved since this is my first sqlite attempt on the iphone/objective c. I've checked all related code and everything I create is being released properly. I don't think I'm over-releasing either. If I don't call[dataSourceObject release]; the program works fine, but I think I should release it since I created it. So I guess that would cause leaks anyway.
What am I doing wrong, any ideas? Thanks in advance.