From b537a01cd13f5b714ffc9123cad4a6a7ec46cd7b Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 29 Jun 2005 02:44:39 +0000 Subject: Prevent reentance of styling which could occur when a styler added a fold point and this caused a search for subordinate lines which then tried to style further. --- src/ScintillaBase.cxx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index c70e2055d..e3aeadc25 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -41,6 +41,7 @@ ScintillaBase::ScintillaBase() { maxListWidth = 0; #ifdef SCI_LEXER lexLanguage = SCLEX_CONTAINER; + performingStyle = false; lexCurrent = 0; for (int wl = 0;wl < numWordLists;wl++) keyWordLists[wl] = new WordList; @@ -469,16 +470,24 @@ void ScintillaBase::Colourise(int start, int end) { #endif void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { + if (!performingStyle) { + // Protect against reentrance, which may occur, for example, when + // fold points are discovered while performing styling and the folding + // code looks for child lines which may trigger styling. + performingStyle = true; #ifdef SCI_LEXER - if (lexLanguage != SCLEX_CONTAINER) { - int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0); - int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0); - endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0); - Colourise(endStyled, endStyleNeeded); - return; - } + if (lexLanguage != SCLEX_CONTAINER) { + int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0); + int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0); + endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0); + Colourise(endStyled, endStyleNeeded); + performingStyle = false; + return; + } #endif - Editor::NotifyStyleToNeeded(endStyleNeeded); + Editor::NotifyStyleToNeeded(endStyleNeeded); + performingStyle = false; + } } sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { -- cgit v1.2.3