Fix possible property access on undefined object

PopupMenuManager allows the insertion of menu without a sourceActor
(or with a null one), but never checks before calling contains() on
it.

https://bugzilla.gnome.org/show_bug.cgi?id=622730
This commit is contained in:
Giovanni Campagna 2010-07-19 23:27:56 +02:00 committed by Dan Winship
parent 13a1175792
commit 4aa80105ca

View File

@ -499,13 +499,14 @@ PopupMenuManager.prototype = {
let src = event.get_source(); let src = event.get_source();
return this._activeMenu != null return this._activeMenu != null
&& (this._activeMenu.actor.contains(src) || && (this._activeMenu.actor.contains(src) ||
this._activeMenu.sourceActor.contains(src)); (this._activeMenu.sourceActor && this._activeMenu.sourceActor.contains(src)));
}, },
_eventIsOnAnyMenuSource: function(event) { _eventIsOnAnyMenuSource: function(event) {
let src = event.get_source(); let src = event.get_source();
for (let i = 0; i < this._menus.length; i++) { for (let i = 0; i < this._menus.length; i++) {
if (this._menus[i].sourceActor.contains(src)) let menu = this._menus[i];
if (menu.sourceActor && menu.sourceActor.contains(src))
return true; return true;
} }
return false; return false;