Skip to content

Commit

Permalink
Merge branch 'develop' into adv-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Jan 14, 2025
2 parents 0c5819f + 072a5ea commit 5bd5f29
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
16 changes: 0 additions & 16 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,13 @@ bool is_builtin(color_ostream &con, const std::string &command) {
}

void get_commands(color_ostream &con, std::vector<std::string> &commands) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Cannot acquire core lock in helpdb.get_commands\n");
commands.clear();
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down Expand Up @@ -630,16 +626,12 @@ static std::string sc_event_name (state_change_event id) {
}

void help_helper(color_ostream &con, const std::string &entry_name) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand All @@ -658,16 +650,12 @@ void help_helper(color_ostream &con, const std::string &entry_name) {
}

void tags_helper(color_ostream &con, const std::string &tag) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down Expand Up @@ -705,16 +693,12 @@ void ls_helper(color_ostream &con, const std::vector<std::string> &params) {
filter.push_back(str);
}

#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down
8 changes: 4 additions & 4 deletions library/include/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ namespace DFHack

void unlock()
{
if (!owns_lock())
return;
/* Restore core owner to previous value */
if (tid == std::thread::id{})
Lua::Core::Reset(core.getConsole(), "suspend");
Expand All @@ -386,7 +384,8 @@ namespace DFHack
}

~CoreSuspenderBase() {
unlock();
if (owns_lock())
unlock();
}

protected:
Expand Down Expand Up @@ -438,7 +437,8 @@ namespace DFHack

// note that this is needed so the destructor will call CoreSuspender::unlock instead of CoreSuspenderBase::unlock
~CoreSuspender() {
unlock();
if (owns_lock())
unlock();
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion scripts
Submodule scripts updated 1 files
+209 −106 gui/rename.lua

0 comments on commit 5bd5f29

Please sign in to comment.