mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-27 15:53:31 +03:00
Avoid force quit
This commit is contained in:
parent
f7c735950d
commit
3e369529b4
@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@interface NeoVimAgent : NSObject
|
@interface NeoVimAgent : NSObject
|
||||||
|
|
||||||
@property (nonatomic) bool useInteractiveZsh;
|
@property (nonatomic) bool useInteractiveZsh;
|
||||||
|
@property (readonly, atomic) bool neoVimIsQuitting;
|
||||||
@property (nonatomic, weak) id <NeoVimUiBridgeProtocol> bridge;
|
@property (nonatomic, weak) id <NeoVimUiBridgeProtocol> bridge;
|
||||||
|
|
||||||
- (instancetype)initWithUuid:(NSString *)uuid;
|
- (instancetype)initWithUuid:(NSString *)uuid;
|
||||||
|
@ -111,6 +111,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (bool)neoVimIsQuitting {
|
||||||
|
return _neoVimIsQuitting == 1;
|
||||||
|
}
|
||||||
|
|
||||||
// We cannot use -dealloc for this since -dealloc is not called until the run loop in the thread stops.
|
// We cannot use -dealloc for this since -dealloc is not called until the run loop in the thread stops.
|
||||||
- (void)quit {
|
- (void)quit {
|
||||||
OSAtomicOr32Barrier(1, &_neoVimIsQuitting);
|
OSAtomicOr32Barrier(1, &_neoVimIsQuitting);
|
||||||
@ -407,9 +411,12 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
|||||||
if (responseCode != kCFMessagePortSuccess) {
|
if (responseCode != kCFMessagePortSuccess) {
|
||||||
log_cfmachport_error(responseCode, msgid, data);
|
log_cfmachport_error(responseCode, msgid, data);
|
||||||
|
|
||||||
[_bridge ipcBecameInvalid:
|
if (_neoVimIsQuitting == 0) {
|
||||||
[NSString stringWithFormat:@"Reason: sending msg to neovim failed for %d with %d", msgid, responseCode]
|
[_bridge ipcBecameInvalid:
|
||||||
];
|
[NSString stringWithFormat:@"Reason: sending msg to neovim failed for %d with %d", msgid, responseCode]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,6 +1441,10 @@ extension NeoVimView {
|
|||||||
public func ipcBecameInvalid(_ reason: String) {
|
public func ipcBecameInvalid(_ reason: String) {
|
||||||
NSLog("ERROR \(#function): force-quitting")
|
NSLog("ERROR \(#function): force-quitting")
|
||||||
DispatchUtils.gui {
|
DispatchUtils.gui {
|
||||||
|
if self.agent.neoVimIsQuitting {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
self.delegate?.ipcBecameInvalid(reason: reason)
|
self.delegate?.ipcBecameInvalid(reason: reason)
|
||||||
self.agent.quit()
|
self.agent.quit()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user