Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I have code which does automatic styling every couple of seconds after changes in a SCINTILLANOTIFICATION.PAINTED handler. However, I found if I registered for notepad notifications (e.g. NOTIFICATION.BUFFERACTIVATED or NOTIFICATION.FILESAVED), and these arrived while I was styling the text, notepad++ would lock up and need killing and restarting.
I managed to simulate BUFFERACTIVATED and FILESAVED by using PAINTED as an idle loop and looking for changes, and my script seems fine now.
Is this because of multi-threading in notepad++ and which Python thread messages are dispatched on?
I would guess it was. Although theoretically, it should be fine, as all scintilla notifications are processed on a consumer thread, and the event returns before the callback is complete, so the scintilla events can occur however they like. Notepad++ events like BUFFERACTIVATED are processed inline, so do not return until the callback is completed.
I can imagine that this is something along the lines of the BUFFERACTIVATED causing a PAINT, which causes your script to set a style, which causes another PAINT, and so on. With enough layers and locks and waits, there's a deadlock hidden in there somewhere.
I will try to reproduce this when I get some time, but with the Python GIL stamping its size 12s around at the same time, it makes for a complex issue, and can't guarantee a fix in the near future (or possibly at all…)
Incidentally, doesn't the MODIFIED notification do what you want - seems a shame to style after every paint, when you really want to style after a modification has been made - I can see that you might be fighting with the real lexer though - in which case, would your own lexer /language definition be a better idea? Just a thought.
Sorry I can't be of more help.
The reason I didn't use MODIFIED was because it tended to crash in odd places. If you just have a basic script which prints out the arguments for an exception, it crashes (I put in a bug report for that). Note that I am using PAINT not for doing styling every time, but as my idle loop. I have a timer which updates it three seconds or so after it was last modified or when it is saved. I basically use a md5 checksum to see when the text has changed.
I have created a follow-up bug from this with a test case as sourceforge won't let me attach here:
Basically, what I am doing in my script is the equivalent of pyflakes-vim - a little bit of extra checking of Python code on top of the regular python syntax highlighting. So it needs to still use the basic python lexer.
Thanks for your time,