Skip to content

Commit

Permalink
disconnect project-changed-event only if connected
Browse files Browse the repository at this point in the history
See #90
  • Loading branch information
Prince781 committed Apr 16, 2020
1 parent 3417984 commit eba1d92
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class Vls.Server : Object {
}

uint[] g_sources = {};
ulong event;
ulong client_closed_event_id;
ulong project_changed_event_id;

static construct {
Process.@signal (ProcessSignal.INT, () => {
Expand Down Expand Up @@ -166,7 +167,7 @@ class Vls.Server : Object {
server.accept_io_stream (new SimpleIOStream (input_stream, output_stream));

#if WITH_JSONRPC_GLIB_3_30
event = server.client_closed.connect (client => {
client_closed_event_id = server.client_closed.connect (client => {
shutdown_real ();
});
#endif
Expand Down Expand Up @@ -370,7 +371,7 @@ class Vls.Server : Object {
check_update_context ();
return !this.shutting_down;
});
project.changed.connect (project_changed_event);
project_changed_event_id = project.changed.connect (project_changed_event);

is_initialized = true;
}
Expand Down Expand Up @@ -1866,9 +1867,10 @@ class Vls.Server : Object {
debug ("shutting down...");
this.shutting_down = true;
cancellable.cancel ();
if (event != 0)
server.disconnect (event);
project.changed.disconnect (project_changed_event);
if (client_closed_event_id != 0)
server.disconnect (client_closed_event_id);
if (project_changed_event_id != 0)
project.disconnect (project_changed_event_id);
loop.quit ();
foreach (uint id in g_sources)
Source.remove (id);
Expand Down

0 comments on commit eba1d92

Please sign in to comment.