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
|
||||
|
||||
@property (nonatomic) bool useInteractiveZsh;
|
||||
@property (readonly, atomic) bool neoVimIsQuitting;
|
||||
@property (nonatomic, weak) id <NeoVimUiBridgeProtocol> bridge;
|
||||
|
||||
- (instancetype)initWithUuid:(NSString *)uuid;
|
||||
|
@ -111,6 +111,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
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.
|
||||
- (void)quit {
|
||||
OSAtomicOr32Barrier(1, &_neoVimIsQuitting);
|
||||
@ -407,9 +411,12 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
if (responseCode != kCFMessagePortSuccess) {
|
||||
log_cfmachport_error(responseCode, msgid, data);
|
||||
|
||||
if (_neoVimIsQuitting == 0) {
|
||||
[_bridge ipcBecameInvalid:
|
||||
[NSString stringWithFormat:@"Reason: sending msg to neovim failed for %d with %d", msgid, responseCode]
|
||||
];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1441,6 +1441,10 @@ extension NeoVimView {
|
||||
public func ipcBecameInvalid(_ reason: String) {
|
||||
NSLog("ERROR \(#function): force-quitting")
|
||||
DispatchUtils.gui {
|
||||
if self.agent.neoVimIsQuitting {
|
||||
return
|
||||
}
|
||||
|
||||
self.delegate?.ipcBecameInvalid(reason: reason)
|
||||
self.agent.quit()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user