1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:28:13 +00:00

AudioServer: Fix visibility of Object-derivative constructors

Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.

This commit is separate from the other Servives changes because it
required additional adaption of the code. Note that the old code did
precisely what these changes try to prevent: Create and handle a
ref-counted object with a refcount of zero.
This commit is contained in:
Ben Wiederhake 2021-10-31 23:38:04 +01:00 committed by Andreas Kling
parent 4e55d649d7
commit 25032a02aa
3 changed files with 6 additions and 4 deletions

View file

@ -29,7 +29,7 @@ int main(int, char**)
unveil(nullptr, nullptr);
Core::EventLoop event_loop;
AudioServer::Mixer mixer { config };
auto mixer = AudioServer::Mixer::construct(config);
auto server = Core::LocalServer::construct();
bool ok = server->take_over_from_system_server();
@ -42,7 +42,7 @@ int main(int, char**)
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, mixer);
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, *mixer);
};
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) {