messageTray: Check monitor's existence before trying to update the state

Not doing this will throw a backtrace when running on headless mode and
trying to show a notification, due to Main.layoutManager.primaryMonitor
being undefined, so it's better to return early.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
This commit is contained in:
Mario Sanchez Prada 2017-09-26 11:03:33 +01:00
parent 9a7dbfba99
commit 023b50e7a7

View File

@ -1205,8 +1205,9 @@ var MessageTray = new Lang.Class({
// _updateState() figures out what (if anything) needs to be done // _updateState() figures out what (if anything) needs to be done
// at the present time. // at the present time.
_updateState: function() { _updateState: function() {
this.actor.visible = !this._bannerBlocked && this._banner != null; let hasMonitor = Main.layoutManager.primaryMonitor != null;
if (this._bannerBlocked) this.actor.visible = !this._bannerBlocked && hasMonitor && this._banner != null;
if (this._bannerBlocked || !hasMonitor)
return; return;
// If our state changes caused _updateState to be called, // If our state changes caused _updateState to be called,