diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index 4207edf16..80cefea74 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -29,6 +29,7 @@ bool (*&DisplayErrorFn())(const Value& v) } int64 Ctrl::eventid; +int Ctrl::EventLevel; Ctrl *Ctrl::LoopCtrl; int Ctrl::LoopLevel; diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 194317ac5..134fad2cf 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -534,6 +534,7 @@ private: static bool globalbackpaint; static bool globalbackbuffer; static bool painting; + static int EventLevel; static int LoopLevel; static Ctrl *LoopCtrl; static int64 EventLoopNo; @@ -729,6 +730,11 @@ private: static void InstallPanicBox(); bool IsDHCtrl() const; + + struct EventLevelDo { + EventLevelDo() { EventLevel++; }; + ~EventLevelDo() { EventLevel--; }; + }; private: void DoRemove(); @@ -1214,9 +1220,11 @@ public: static bool IsWaitingEvent(); static bool ProcessEvent(bool *quit = NULL); static bool ProcessEvents(bool *quit = NULL); + static int GetEventLevel() { return EventLevel; } bool IsPopUp() const { return popup; } + static void EventLoop(Ctrl *loopctrl = NULL); static int GetLoopLevel() { return LoopLevel; } static Ctrl *GetLoopCtrl() { return LoopCtrl; } diff --git a/uppsrc/CtrlCore/CtrlKbd.cpp b/uppsrc/CtrlCore/CtrlKbd.cpp index 2044c4721..aa64c3c75 100644 --- a/uppsrc/CtrlCore/CtrlKbd.cpp +++ b/uppsrc/CtrlCore/CtrlKbd.cpp @@ -38,6 +38,7 @@ void Ctrl::RefreshAccessKeysDo(bool vis) bool Ctrl::DispatchKey(dword keycode, int count) { GuiLock __; + EventLevelDo ___; if(GUI_AltAccessKeys()) { bool alt = GetAlt(); Ctrl *c = GetActiveCtrl(); diff --git a/uppsrc/CtrlCore/CtrlMouse.cpp b/uppsrc/CtrlCore/CtrlMouse.cpp index 0cd81fa70..ac7fce29e 100644 --- a/uppsrc/CtrlCore/CtrlMouse.cpp +++ b/uppsrc/CtrlCore/CtrlMouse.cpp @@ -524,6 +524,7 @@ bool sDblTime(int time) Image Ctrl::DispatchMouse(int e, Point p, int zd) { GuiLock __; + EventLevelDo ___; if(e == MOUSEWHEEL && !zd) // ignore non-scroll wheel events return Null; if(e == MOUSEMOVE && repeatTopCtrl == this) { diff --git a/uppsrc/CtrlCore/src.tpp/Ctrl_en-us.tpp b/uppsrc/CtrlCore/src.tpp/Ctrl_en-us.tpp index 8ea9a143b..acea6148d 100644 --- a/uppsrc/CtrlCore/src.tpp/Ctrl_en-us.tpp +++ b/uppsrc/CtrlCore/src.tpp/Ctrl_en-us.tpp @@ -2423,6 +2423,16 @@ intercepted (Win32 specific).&] were processed, false that queue was empty.&] [s3;%- &] [s4;%- &] +[s5;:Upp`:`:Ctrl`:`:GetEventLevel`(`):%- [@(0.0.255) static] [@(0.0.255) int]_[* GetEventLe +vel]()&] +[s2; Returns the level of input event. This is basically a reentrancy +level of ProcessEvent(s) routine `- it starts zero but increments +each time the input event is generated by ProcessEvent(s). This +information can be useful for background threads or in timer +events (where this is zero when application is in the `"base`" +state).&] +[s3;%- &] +[s4;%- &] [s5;:Ctrl`:`:IsPopUp`(`)const:%- [@(0.0.255) bool]_[* IsPopUp]()_[@(0.0.255) const]&] [s7;i1120;a17; [*/ Return value]-|True if Ctrl is pop`-up window.&] [s3; &] diff --git a/uppsrc/GLDraw/Text.cpp b/uppsrc/GLDraw/Text.cpp index 826dc69a5..b90a6cfbe 100644 --- a/uppsrc/GLDraw/Text.cpp +++ b/uppsrc/GLDraw/Text.cpp @@ -69,7 +69,7 @@ void GLDrawText(const GLContext2D& dd, Pointf pos, double angle, const wchar *te if(angle) u = Polar(-angle); if(n < 0) - n = wstrlen(text); + n = strlen__(text); for(int i = 0; i < n; i++) { GLTexture m = GetGlyphGLTextureCached(-angle, text[i], font, ink); Point h = m.GetHotSpot(); diff --git a/uppsrc/ide/ide.cpp b/uppsrc/ide/ide.cpp index 57e94d22d..01b5b6bd0 100644 --- a/uppsrc/ide/ide.cpp +++ b/uppsrc/ide/ide.cpp @@ -645,10 +645,8 @@ void Ide::Periodic() SetIcon(); if(debugger && debugger->IsFinished() && !IdeIsDebugLock()) IdeEndDebug(); - if(file_scanned) { - if(EditFileAssistSync2()) - file_scanned = false; - } + if(file_scanned && Ctrl::GetEventLevel() == 0 && EditFileAssistSync2()) + file_scanned = false; } const Workspace& Ide::IdeWorkspace() const diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index 69461d186..2edb4a6db 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -686,7 +686,7 @@ void Ide::TriggerAssistSync() String s = ~editor; String fn = editfile; file_scan++; - if(!CoWork::TrySchedule([=] { + if(Ctrl::GetEventLevel() == 0 && !CoWork::TrySchedule([=] { StringStream ss(s); file_scanned = TryCodeBaseScanFile(ss, editfile); file_scan--;