mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
iCloud: fix storing variables that don't survive to the async callback (#16849)
This commit is contained in:
parent
41b97e4688
commit
d4cb4953a6
@ -88,8 +88,10 @@ static void icloud_query_path(const char *path, void(^cb)(CKRecord * results, NS
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool icloud_read(const char *path, const char *file, cloud_sync_complete_handler_t cb, void *user_data)
|
static bool icloud_read(const char *p, const char *f, cloud_sync_complete_handler_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
|
char *path = strdup(p);
|
||||||
|
char *file = strdup(f);
|
||||||
icloud_query_path(path, ^(CKRecord *result, NSError *error) {
|
icloud_query_path(path, ^(CKRecord *result, NSError *error) {
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@ -116,16 +118,23 @@ static bool icloud_read(const char *path, const char *file, cloud_sync_complete_
|
|||||||
}
|
}
|
||||||
cb(user_data, path, true, rfile);
|
cb(user_data, path, true, rfile);
|
||||||
}
|
}
|
||||||
|
free(path);
|
||||||
|
free(file);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cb(user_data, path, error == nil, NULL);
|
cb(user_data, path, error == nil, NULL);
|
||||||
|
free(path);
|
||||||
|
free(file);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool icloud_update(const char *path, RFILE *rfile, cloud_sync_complete_handler_t cb, void *user_data)
|
static bool icloud_update(const char *p, RFILE *rfile, cloud_sync_complete_handler_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
|
char *path = strdup(p);
|
||||||
icloud_query_path(path, ^(CKRecord *record, NSError *error) {
|
icloud_query_path(path, ^(CKRecord *record, NSError *error) {
|
||||||
bool update = true;
|
bool update = true;
|
||||||
if (error || !record)
|
if (error || !record)
|
||||||
@ -142,13 +151,15 @@ static bool icloud_update(const char *path, RFILE *rfile, cloud_sync_complete_ha
|
|||||||
if (error)
|
if (error)
|
||||||
RARCH_DBG("[iCloud] error: %s\n", [[error debugDescription] UTF8String]);
|
RARCH_DBG("[iCloud] error: %s\n", [[error debugDescription] UTF8String]);
|
||||||
cb(user_data, path, error == nil, rfile);
|
cb(user_data, path, error == nil, rfile);
|
||||||
|
free(path);
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool icloud_delete(const char *path, cloud_sync_complete_handler_t cb, void *user_data)
|
static bool icloud_delete(const char *p, cloud_sync_complete_handler_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
|
char *path = strdup(p);
|
||||||
NSPredicate *pred = [NSComparisonPredicate
|
NSPredicate *pred = [NSComparisonPredicate
|
||||||
predicateWithLeftExpression:[NSExpression expressionForKeyPath:@"path"]
|
predicateWithLeftExpression:[NSExpression expressionForKeyPath:@"path"]
|
||||||
rightExpression:[NSExpression expressionForConstantValue:[NSString stringWithUTF8String:path]]
|
rightExpression:[NSExpression expressionForConstantValue:[NSString stringWithUTF8String:path]]
|
||||||
@ -170,6 +181,7 @@ static bool icloud_delete(const char *path, cloud_sync_complete_handler_t cb, vo
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
cb(user_data, path, error == nil, NULL);
|
cb(user_data, path, error == nil, NULL);
|
||||||
|
free(path);
|
||||||
}];
|
}];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user