1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

HackStudio: Detach from debugged process before terminating

Fixes #3308
This commit is contained in:
Itamar 2020-09-26 11:23:49 +03:00 committed by Andreas Kling
parent 8ce641cefc
commit 8af67210cf
6 changed files with 63 additions and 37 deletions

View file

@ -678,9 +678,15 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent)
GUI::WidgetClassRegistration::for_each([&, this](const GUI::WidgetClassRegistration& reg) {
constexpr size_t gui_namespace_prefix_length = sizeof("GUI::") - 1;
auto icon_path = String::format("/res/icons/hackstudio/G%s.png", reg.class_name().substring(gui_namespace_prefix_length, reg.class_name().length() - gui_namespace_prefix_length).characters());
auto icon_path = String::format(
"/res/icons/hackstudio/G%s.png",
reg.class_name().substring(
gui_namespace_prefix_length,
reg.class_name().length() - gui_namespace_prefix_length)
.characters());
if (!Core::File::exists(icon_path))
return;
auto action = GUI::Action::create_checkable(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [&reg, this](auto&) {
m_form_editor_widget->set_tool(make<WidgetTool>(*m_form_editor_widget, reg));
auto widget = reg.construct();
@ -899,4 +905,18 @@ void HackStudioWidget::initialize_menubar(GUI::MenuBar& menubar)
create_help_menubar(menubar);
}
HackStudioWidget::~HackStudioWidget()
{
if (!m_debugger_thread.is_null()) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Exit);
void* retval;
dbg() << "Waiting for debugger thread to terminate";
int rc = pthread_join(m_debugger_thread->tid(), &retval);
if (rc < 0) {
perror("pthread_join");
dbg() << "error joining debugger thread";
}
}
}
}