Re: CFDictionaryCreateMutableCopy crash
Re: CFDictionaryCreateMutableCopy crash
- Subject: Re: CFDictionaryCreateMutableCopy crash
- From: Frederick Cheung <email@hidden>
- Date: Thu, 23 Sep 2004 12:50:14 +0200
On 23 Sep 2004, at 11:08, Gábor Sebestyén wrote:
Hi,
I actually write a C++ wrapper class upon CFPreferences. In a value
writer method the program crashes when it tries to create a mutable
copy from a freshly retrieved dictionary.
The code is:
void Config::WriteInt(char* section, char* key, int value)
{
CFStringRef ksect = MY_CFSTRING(section); //section
CFStringRef kdict = MY_CFSTRING(key); //key in dict
CFNumberRef val = CFNumberCreate(NULL, kCFNumberIntType, &value);
CFDictionaryRef dict0 = CFPreferencesCopyAppValue(ksect,
kCFPreferencesCurrentApplication);
CFMutableDictionaryRef dict;
if (dict0) {
CRASH HERE! => dict = CFDictionaryCreateMutableCopy(NULL, 0, dict0);
CFRelease(dict0);
} else {
dict = CFDictionaryCreateMutable(NULL, 1, NULL, NULL);
}
...
That code in itself is ok, i think you are doing something somewhere
else that is getting cfpreferences confused. I am a little suspicious
of how you create dict in the case that dict0 is NULL. Are you aware
that such a dictionary will not retain values added to it (or the keys)
? If not that could be your problem, if you are releasing values you
add to that dictionary (inadvertently destroying them).
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden