diff options
author | Naios <naios-dev@live.de> | 2016-04-14 21:27:39 +0200 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2016-04-14 21:30:52 +0200 |
commit | 19bf0513bcb17f5eac40a34dfb2349337c7a3cb5 (patch) | |
tree | 3c4f8d919953ae55cdc90fc6d65529af0465c689 /src/server/game/Scripting/ScriptReloadMgr.cpp | |
parent | 2038c311001982dba100d33a6fbb8797f9de1c87 (diff) |
Core/Scripting: Wait until the debugger is detached before rebuilding scripts.
* Thanks Shauren for the IsDebuggerPresent() hint.
(cherry picked from commit b970a68473eb6a7a7b71ab4a5c13338bb5cafc89)
Diffstat (limited to 'src/server/game/Scripting/ScriptReloadMgr.cpp')
-rw-r--r-- | src/server/game/Scripting/ScriptReloadMgr.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp index f13bd16d6c6..2630e48b0ef 100644 --- a/src/server/game/Scripting/ScriptReloadMgr.cpp +++ b/src/server/game/Scripting/ScriptReloadMgr.cpp @@ -342,6 +342,17 @@ static std::string CalculateScriptModuleProjectName(std::string const& module) return module_project; } +/// Returns false when there isn't any attached debugger to the process which +/// could block the rebuild of new shared libraries. +static bool IsDebuggerBlockingRebuild() +{ +#ifdef _WIN32 + if (IsDebuggerPresent()) + return true; +#endif + return false; +} + /// ScriptReloadMgr which is used when dynamic linking is enabled /// /// This class manages shared library loading/unloading through watching @@ -476,7 +487,7 @@ public: HotSwapScriptReloadMgr() : _libraryWatcher(-1), _unique_library_name_counter(0), _last_time_library_changed(0), _last_time_sources_changed(0), - terminate_early(false) { } + _last_time_user_informed(0), terminate_early(false) { } virtual ~HotSwapScriptReloadMgr() { @@ -957,6 +968,22 @@ private: // If the changed sources are empty do nothing if (_sources_changed.empty()) return; + + // Wait until are attached debugger were detached. + if (IsDebuggerBlockingRebuild()) + { + if ((_last_time_user_informed == 0) || + (GetMSTimeDiffToNow(_last_time_user_informed) > 7500)) + { + _last_time_user_informed = getMSTime(); + + // Informs the user that the attached debugger is blocking the automatic script rebuild. + TC_LOG_INFO("scripts.hotswap", "Your attached debugger is blocking the TinityCore " + "automatic script rebuild, please detach it!"); + } + + return; + } // Find all source files of a changed script module and removes // it from the changed source list, invoke the build afterwards. @@ -1308,6 +1335,9 @@ private: // Tracks the time since the last module has changed to avoid burst updates uint32 _last_time_sources_changed; + // Tracks the last timestamp the user was informed about a certain repeating event. + uint32 _last_time_user_informed; + // Represents the current build job which is in progress Optional<BuildJob> _build_job; |