From 3db999ff2d3324ffad6ba6a469ca224c8d864dc3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 28 Aug 2013 22:45:19 +0300 Subject: add some more missing checks. --- src/gui/widgets/scrollarea.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/gui/widgets/scrollarea.cpp') diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 98b58f51c..c21ddd17c 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -102,9 +102,9 @@ ScrollArea::~ScrollArea() const Theme *const theme = Theme::instance(); if (theme) { - theme->unloadRect(background); if (instances == 0) { + theme->unloadRect(background); theme->unloadRect(vMarker); theme->unloadRect(vMarkerHi); theme->unloadRect(vBackground); @@ -135,12 +135,6 @@ void ScrollArea::init(std::string skinName) setLeftButtonScrollAmount(2); setRightButtonScrollAmount(2); - if (skinName == "") - skinName = "scroll_background.xml"; - Theme *const theme = Theme::instance(); - if (theme) - theme->loadRect(background, skinName, "scroll_background.xml"); - if (instances == 0) { for (int f = 0; f < 9; f ++) @@ -152,6 +146,13 @@ void ScrollArea::init(std::string skinName) hBackground.grid[f] = nullptr; } + // +++ here probably need move background from static + if (skinName == "") + skinName = "scroll_background.xml"; + Theme *const theme = Theme::instance(); + if (theme) + theme->loadRect(background, skinName, "scroll_background.xml"); + if (theme) { theme->loadRect(vMarker, "scroll.xml", ""); @@ -169,7 +170,8 @@ void ScrollArea::init(std::string skinName) const ImageRect &rect = skin->getBorder(); for (int f = UP; f < BUTTONS_DIR; f ++) { - rect.grid[f]->incRef(); + if (rect.grid[f]) + rect.grid[f]->incRef(); buttons[f][i] = rect.grid[f]; } if (i == 0) @@ -188,7 +190,6 @@ void ScrollArea::init(std::string skinName) } } mScrollbarWidth = mScrollbarSize; - instances++; } -- cgit v1.2.3-70-g09d2