summaryrefslogtreecommitdiff
path: root/src/gui/windows/shortcutwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-24 14:55:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-25 20:06:07 +0300
commit9d521a19be347703bfdbb7802d0397a59c3edd7a (patch)
tree9a4e56edc84d5cfd8ebaea17fa19296c51e1e661 /src/gui/windows/shortcutwindow.cpp
parent841fe55e67ea467a8e2192dee5c169d282a35148 (diff)
downloadmv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.gz
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.bz2
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.tar.xz
mv-9d521a19be347703bfdbb7802d0397a59c3edd7a.zip
Add missing checks in windows.
Diffstat (limited to 'src/gui/windows/shortcutwindow.cpp')
-rw-r--r--src/gui/windows/shortcutwindow.cpp32
1 files changed, 19 insertions, 13 deletions
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);