Capture parent SystemWindow on click, exit if null

- Issue MatterHackers/MCCentral#4567
Null reference error in ShowPopup.widgetRelativeTo_PositionChanged
This commit is contained in:
John Lewin 2018-11-29 17:07:08 -08:00
parent 13001df42f
commit 62055129b4
2 changed files with 7 additions and 3 deletions

View file

@ -296,14 +296,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
subMenuItemButton.Click += (s, e) =>
{
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
if (systemWindow == null)
{
return;
}
var subMenu = new PopupMenu(menuTheme);
subMenuItemButton.SubMenu = subMenu;
UiThread.RunOnIdle(() =>
{
populateSubMenu(subMenu);
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
systemWindow.ShowPopup(
new MatePoint(subMenuItemButton)
{