From 9d521a19be347703bfdbb7802d0397a59c3edd7a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Jun 2015 14:55:44 +0300 Subject: Add missing checks in windows. --- src/gui/windows/shortcutwindow.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/gui/windows/shortcutwindow.cpp') diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 87c539089..df9aced4c 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -68,27 +68,31 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title, mDragOffsetX = 0; mDragOffsetY = 0; - content->setWidget2(this); + if (content) + content->setWidget2(this); if (setupWindow) setupWindow->registerWindowForReset(this); - const int border = SCROLL_PADDING * 2 + getPadding() * 2; - const int bw = mItems->getBoxWidth(); - const int bh = mItems->getBoxHeight(); - const int maxItems = mItems->getMaxItems(); setMinWidth(32); setMinHeight(32); - setMaxWidth(bw * maxItems + border); - setMaxHeight(bh * maxItems + border); + const int border = SCROLL_PADDING * 2 + getPadding() * 2; + if (mItems) + { + const int bw = mItems->getBoxWidth(); + const int bh = mItems->getBoxHeight(); + const int maxItems = mItems->getMaxItems(); + setMaxWidth(bw * maxItems + border); + setMaxHeight(bh * maxItems + border); - if (width == 0) - width = bw + border; - if (height == 0) - height = bh * maxItems + border; + if (width == 0) + width = bw + border; + if (height == 0) + height = bh * maxItems + border; - setDefaultSize(width, height, ImageRect::LOWER_RIGHT); + setDefaultSize(width, height, ImageRect::LOWER_RIGHT); - mBoxesWidth += bw + border; + mBoxesWidth += bw + border; + } mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); @@ -161,6 +165,8 @@ void ShortcutWindow::addButton(const std::string &text, void ShortcutWindow::addTab(const std::string &name, ShortcutContainer *const content) { + if (!content) + return; ScrollArea *const scroll = new ScrollArea(this, content, false); scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); -- cgit v1.2.3-60-g2f50