summaryrefslogtreecommitdiffstats
path: root/macosx/HBPresetsManager.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-05-30 07:45:00 +0000
committerritsuka <[email protected]>2015-05-30 07:45:00 +0000
commit39eff9d080effd0138c91f397632d24b38f7a441 (patch)
tree04e529f8b72ad44a628c6717a3b80afcc3950bb2 /macosx/HBPresetsManager.m
parent2837048a59ac5beab0b3428ca89c86857765de0a (diff)
MacGui: fix the leaks after using hb_presets_import_json and hb_presets_clean_json, add an extension to NSJSONSerialization to convert a char * directly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7245 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPresetsManager.m')
-rw-r--r--macosx/HBPresetsManager.m15
1 files changed, 8 insertions, 7 deletions
diff --git a/macosx/HBPresetsManager.m b/macosx/HBPresetsManager.m
index 29205e371..121473638 100644
--- a/macosx/HBPresetsManager.m
+++ b/macosx/HBPresetsManager.m
@@ -8,6 +8,7 @@
#import "HBPreset.h"
#import "HBUtilities.h"
+#import "NSJSONSerialization+HBAdditions.h"
#include "preset.h"
@@ -105,18 +106,18 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification";
else
{
const char *json = [[NSString alloc] initWithData:presetData encoding:NSUTF8StringEncoding].UTF8String;
- const char *cleanedJson = hb_presets_clean_json(json);
-
- NSData *cleanedData = [NSData dataWithBytes:cleanedJson length:strlen(cleanedJson)];
- NSDictionary *presetsDict = [NSJSONSerialization JSONObjectWithData:cleanedData options:0 error:NULL];
+ char *cleanedJson = hb_presets_clean_json(json);
+ NSDictionary *presetsDict = [NSJSONSerialization HB_JSONObjectWithUTF8String:cleanedJson options:0 error:NULL];
if ([self checkIfOutOfDate:presetsDict])
{
- const char *updatedJson = hb_presets_import_json(cleanedJson);
- NSData *updatedData = [NSData dataWithBytes:updatedJson length:strlen(cleanedJson)];
- presetsDict = [NSJSONSerialization JSONObjectWithData:updatedData options:0 error:NULL];
+ char *updatedJson = hb_presets_import_json(cleanedJson);
+ presetsDict = [NSJSONSerialization HB_JSONObjectWithUTF8String:updatedJson options:0 error:NULL];
+ free(updatedJson);
}
+ free(cleanedJson);
+
for (NSDictionary *child in presetsDict[@"PresetList"])
{
[self.root.children addObject:[[HBPreset alloc] initWithDictionary:child]];