Skip to content

Commit

Permalink
Bus.prototype.reconnect to handle null connection
Browse files Browse the repository at this point in the history
  • Loading branch information
petervizi committed Feb 1, 2020
1 parent 0dcaea8 commit d333ec6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Bus.prototype.disconnect = function(callback) {
Bus.prototype.reconnect = function(callback) {
var self = this;

delete self.DBus.signalHandlers[self.connection.uniqueName];
if(self.connection) {
delete self.DBus.signalHandlers[self.connection.uniqueName];

self._dbus.releaseBus(self.connection);
self._dbus.releaseBus(self.connection);
}

switch(self.name) {
case 'system':
Expand All @@ -88,7 +90,7 @@ Bus.prototype.reconnect = function(callback) {
self.connection = self._dbus.getBus(1);
break;
}

self.DBus.signalHandlers[self.connection.uniqueName] = self;

// Reregister signal handler
Expand Down Expand Up @@ -246,4 +248,3 @@ Bus.prototype.callMethod = function() {
args.push(createError);
this._dbus.callMethod.apply(this, args);
};

0 comments on commit d333ec6

Please sign in to comment.