mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/Scripting: Wait until the debugger is detached before rebuilding scripts.
* Thanks Shauren for the IsDebuggerPresent() hint.
This commit is contained in:
@@ -342,6 +342,17 @@ static std::string CalculateScriptModuleProjectName(std::string const& module)
|
|||||||
return module_project;
|
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
|
/// ScriptReloadMgr which is used when dynamic linking is enabled
|
||||||
///
|
///
|
||||||
/// This class manages shared library loading/unloading through watching
|
/// This class manages shared library loading/unloading through watching
|
||||||
@@ -476,7 +487,7 @@ public:
|
|||||||
HotSwapScriptReloadMgr()
|
HotSwapScriptReloadMgr()
|
||||||
: _libraryWatcher(-1), _unique_library_name_counter(0),
|
: _libraryWatcher(-1), _unique_library_name_counter(0),
|
||||||
_last_time_library_changed(0), _last_time_sources_changed(0),
|
_last_time_library_changed(0), _last_time_sources_changed(0),
|
||||||
terminate_early(false) { }
|
_last_time_user_informed(0), terminate_early(false) { }
|
||||||
|
|
||||||
virtual ~HotSwapScriptReloadMgr()
|
virtual ~HotSwapScriptReloadMgr()
|
||||||
{
|
{
|
||||||
@@ -957,6 +968,22 @@ private:
|
|||||||
// If the changed sources are empty do nothing
|
// If the changed sources are empty do nothing
|
||||||
if (_sources_changed.empty())
|
if (_sources_changed.empty())
|
||||||
return;
|
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
|
// Find all source files of a changed script module and removes
|
||||||
// it from the changed source list, invoke the build afterwards.
|
// 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
|
// Tracks the time since the last module has changed to avoid burst updates
|
||||||
uint32 _last_time_sources_changed;
|
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
|
// Represents the current build job which is in progress
|
||||||
Optional<BuildJob> _build_job;
|
Optional<BuildJob> _build_job;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user