diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2019-07-31 20:13:33 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-07-31 20:15:20 +0300 |
commit | 7481749d58ff5e5cfc59baf48f9d82c2099abdc2 (patch) | |
tree | a67d587feb8d472049f99834c8a5e316052e8d0e /main | |
parent | a9c742622b1bea50ed3304c8bfcefd772e6ae215 (diff) |
Fix stack overflow at startup
The IdeApp.DispatchIdleActions method is sometimes called just after startup.
When that happens, if the user has not had any interaction with the ide,
the CommandService.LastUserInteration property will have the default DateTime
value. The old code was substracting that value from the current time, which
would be a huge amount of milliseconds, and would overflow when converting
to int. It all would result with DispatchIdleActions being called over and over
with a negative number, finally causing a stack overflow.
Fixes VSTS #958148
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index da8982d467..1776fbeb3b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -541,9 +541,9 @@ namespace MonoDevelop.Ide // If the user interacted with the IDE just a moment ago, wait a bit more time before // running the action - var interactionSpan = (int)(DateTime.Now - commandService.LastUserInteraction).TotalMilliseconds; + var interactionSpan = Math.Max (0, (DateTime.Now - commandService.LastUserInteraction).TotalMilliseconds); if (interactionSpan < 500) { - DispatchIdleActions (500 - interactionSpan); + DispatchIdleActions (500 - (int) interactionSpan); return; } |