Bug 1366352 - Post: check anchor is set before trying to show GeckoPopupMenu r=nechen

This means we'll at least see a sensible exception, instead of an NPE when
no anchor is set. That makes it easier to debug cases where no anchor was
set (see e.g. the main commit from this bug).

MozReview-Commit-ID: CzsZaHvnZ6y

--HG--
extra : rebase_source : 2aaf737b49367d9e70fc62a1226e038c79f573e3
This commit is contained in:
Andrzej Hunt 2017-05-19 12:17:25 -07:00
parent f9367a3210
commit 657c2807d0

View File

@ -137,6 +137,10 @@ public class GeckoPopupMenu implements GeckoMenu.Callback,
* Show the inflated menu.
*/
public void show() {
if (mAnchor == null) {
throw new IllegalStateException("GeckoPopupMenu.show() called without preceeding call to setAnchor()");
}
if (!mMenuPopup.isShowing())
mMenuPopup.showAsDropDown(mAnchor);
}