mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
Destroy all remaining windows in a process when it dies.
This commit is contained in:
parent
3a4207b863
commit
5c25f0c4db
7 changed files with 30 additions and 6 deletions
|
@ -1490,9 +1490,10 @@ int Process::reap(Process& process)
|
|||
|
||||
if (process.ppid()) {
|
||||
auto* parent = Process::from_pid(process.ppid());
|
||||
ASSERT(parent);
|
||||
parent->m_ticks_in_user_for_dead_children += process.m_ticks_in_user + process.m_ticks_in_user_for_dead_children;
|
||||
parent->m_ticks_in_kernel_for_dead_children += process.m_ticks_in_kernel + process.m_ticks_in_kernel_for_dead_children;
|
||||
if (parent) {
|
||||
parent->m_ticks_in_user_for_dead_children += process.m_ticks_in_user + process.m_ticks_in_user_for_dead_children;
|
||||
parent->m_ticks_in_kernel_for_dead_children += process.m_ticks_in_kernel + process.m_ticks_in_kernel_for_dead_children;
|
||||
}
|
||||
}
|
||||
|
||||
dbgprintf("reap: %s(%u) {%s}\n", process.name().characters(), process.pid(), toString(process.state()));
|
||||
|
@ -2143,4 +2144,5 @@ void Process::die()
|
|||
{
|
||||
set_state(Dead);
|
||||
m_fds.clear();
|
||||
destroy_all_windows();
|
||||
}
|
||||
|
|
|
@ -216,6 +216,7 @@ public:
|
|||
static void initialize();
|
||||
static void initialize_gui_statics();
|
||||
int make_window_id();
|
||||
void destroy_all_windows();
|
||||
|
||||
void crash() NORETURN;
|
||||
static int reap(Process&) WARN_UNUSED_RESULT;
|
||||
|
|
|
@ -257,3 +257,12 @@ int Process::gui$set_global_cursor_tracking_enabled(int window_id, bool enabled)
|
|||
window.set_global_cursor_tracking_enabled(enabled);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Process::destroy_all_windows()
|
||||
{
|
||||
for (auto& it : m_windows) {
|
||||
auto message = make<WSMessage>(WSMessage::WM_DestroyWindow);
|
||||
WSMessageLoop::the().post_message(it.value.leakPtr(), move(message), true);
|
||||
}
|
||||
m_windows.clear();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public:
|
|||
WM_SetWindowTitle,
|
||||
WM_SetWindowRect,
|
||||
WM_DeferredCompose,
|
||||
WM_DestroyWindow,
|
||||
MouseMove,
|
||||
MouseDown,
|
||||
MouseUp,
|
||||
|
|
|
@ -71,9 +71,15 @@ int WSMessageLoop::exec()
|
|||
}
|
||||
}
|
||||
|
||||
void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&& message)
|
||||
void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&& message, bool unsafe)
|
||||
{
|
||||
ASSERT_INTERRUPTS_ENABLED();
|
||||
if (unsafe) {
|
||||
// FIXME: This is such a hack. It should not exist.
|
||||
m_queued_messages.append({ receiver, move(message) });
|
||||
if (current != m_server_process)
|
||||
m_server_process->request_wakeup();
|
||||
return;
|
||||
}
|
||||
LOCKER(m_lock);
|
||||
#ifdef WSEVENTLOOP_DEBUG
|
||||
dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p\n", m_queued_messages.size(), receiver, message.ptr());
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
|
||||
int exec();
|
||||
|
||||
void post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&&);
|
||||
void post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&&, bool unsafe = false);
|
||||
|
||||
static WSMessageLoop& the();
|
||||
|
||||
|
|
|
@ -107,12 +107,17 @@ void WSWindow::on_message(WSMessage& message)
|
|||
case WSMessage::WM_SetWindowTitle:
|
||||
set_title(static_cast<WSSetWindowTitleMessage&>(message).title());
|
||||
return;
|
||||
case WSMessage::WM_DestroyWindow:
|
||||
delete this;
|
||||
return;
|
||||
case WSMessage::WindowActivated:
|
||||
gui_event.type = GUI_Event::Type::WindowActivated;
|
||||
break;
|
||||
case WSMessage::WindowDeactivated:
|
||||
gui_event.type = GUI_Event::Type::WindowDeactivated;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (gui_event.type == GUI_Event::Type::Invalid)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue