Fix crash: posting Vim message from thread
Vim is not thread-safe so posting a message to Vim from a non-GUI thread causes a crash *sometimes*. I was aware of this problem before, but didn't catch this instance of it in code review. Fixes #479.
This commit is contained in:
parent
f347885555
commit
4374da616e
@ -167,10 +167,9 @@ class CsharpCompleter( ThreadedCompleter ):
|
||||
try:
|
||||
response = urllib2.urlopen( target, parameters )
|
||||
return json.loads( response.read() )
|
||||
except Exception as e:
|
||||
if not silent:
|
||||
vimsupport.PostVimMessage(
|
||||
'OmniSharp : Could not connect to ' + target + ': ' + str( e ) )
|
||||
except Exception:
|
||||
# TODO: Add logging for this case. We can't post a Vim message because Vim
|
||||
# crashes when that's done from a no-GUI thread.
|
||||
return None
|
||||
|
||||
|
||||
|
@ -79,6 +79,10 @@ def NumLinesInBuffer( buffer ):
|
||||
|
||||
|
||||
def PostVimMessage( message ):
|
||||
# TODO: Check are we on the main thread or not, and if not, force a crash
|
||||
# here. This should make it impossible to accidentally call this from a
|
||||
# non-GUI thread which *sometimes* crashes Vim because Vim is not thread-safe.
|
||||
# A consistent crash should force us to notice the error.
|
||||
vim.command( "echohl WarningMsg | echomsg '{0}' | echohl None"
|
||||
.format( EscapeForVim( message ) ) )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user