1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00

GH-339 Use autorelease pool in the callbacks to be sure

This commit is contained in:
Tae Won Ha 2017-01-06 14:06:27 +01:00
parent 3a61567590
commit 3d4867c232
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -14,7 +14,6 @@
#import "NeoVimTab.h"
#import "CocoaCategories.h"
#import "DataWrapper.h"
#import "vim.h"
// FileInfo and Boolean are #defined by Carbon and NeoVim: Since we don't need the Carbon versions of them, we rename
// them.
@ -512,22 +511,31 @@ void quit_neovim() {
}
#pragma mark Functions for neovim's main loop
// already in an autorelease pool and in neovim's main loop
typedef NSData *(^work_block)(NSData *);
static void work_and_write_data_sync(void **argv, work_block block) {
NSCondition *outputCondition = argv[1];
[outputCondition lock];
@autoreleasepool {
NSCondition *outputCondition = argv[1];
[outputCondition lock];
NSData *data = argv[0];
DataWrapper *wrapper = argv[2];
wrapper.data = block(data);
wrapper.dataReady = YES;
[data release]; // retained in local_server_callback
NSData *data = argv[0];
DataWrapper *wrapper = argv[2];
wrapper.data = block(data);
wrapper.dataReady = YES;
[data release]; // retained in local_server_callback
[outputCondition signal];
[outputCondition unlock];
[outputCondition signal];
[outputCondition unlock];
}
}
static void work_async(void **argv, work_block block) {
@autoreleasepool {
NSData *data = argv[0];
block(data);
[data release]; // retained in local_server_callback
}
}
static NSString *escaped_filename(NSString *filename) {
@ -540,12 +548,6 @@ static NSString *escaped_filename(NSString *filename) {
return result;
}
static void work_async(void **argv, work_block block) {
NSData *data = argv[0];
block(data);
[data release]; // retained in local_server_callback
}
static NeoVimBuffer *buffer_for(buf_T *buf) {
// To be sure...
if (buf == NULL) {