mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 09:17:38 +03:00
SpiceAgent: Gracefully exit when the Spice server disconnects
This commit is contained in:
parent
36d61c01bc
commit
35fdc7f8c8
Notes:
sideshowbarker
2024-07-17 05:06:13 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/35fdc7f8c8 Pull-request: https://github.com/SerenityOS/serenity/pull/18980
@ -217,6 +217,12 @@ ErrorOr<void> SpiceAgent::on_message_received()
|
||||
dbgln_if(SPICE_AGENT_DEBUG, "Ignored message: {}", header);
|
||||
break;
|
||||
|
||||
case Message::Type::Disconnected:
|
||||
dbgln_if(SPICE_AGENT_DEBUG, "Spice server disconnected");
|
||||
if (on_disconnected_from_spice_server)
|
||||
on_disconnected_from_spice_server();
|
||||
break;
|
||||
|
||||
default:
|
||||
dbgln("Unknown message received: {}", header);
|
||||
break;
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
Function<void()> on_disconnected_from_spice_server;
|
||||
|
||||
private:
|
||||
NonnullOwnPtr<Core::File> m_spice_device;
|
||||
Vector<Capability> m_capabilities;
|
||||
|
@ -35,7 +35,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto agent = TRY(SpiceAgent::SpiceAgent::create(SPICE_DEVICE));
|
||||
TRY(agent->start());
|
||||
|
||||
agent->on_disconnected_from_spice_server = [&]() {
|
||||
app->quit();
|
||||
};
|
||||
|
||||
TRY(agent->start());
|
||||
return app->exec();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user