summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-28 15:18:58 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-29 00:18:56 +0300
commitafbf2f713dd918bd0ff050d71afbf05bc581ab6e (patch)
tree6a06804aa813ed184b1293ab458929d372285385 /src
parent482cbfc4e1299434a6f632fe7f4b4e3704e65e87 (diff)
downloadplus-afbf2f713dd918bd0ff050d71afbf05bc581ab6e.tar.gz
plus-afbf2f713dd918bd0ff050d71afbf05bc581ab6e.tar.bz2
plus-afbf2f713dd918bd0ff050d71afbf05bc581ab6e.tar.xz
plus-afbf2f713dd918bd0ff050d71afbf05bc581ab6e.zip
fix some missing checks.
Diffstat (limited to 'src')
-rw-r--r--src/gui/theme.cpp15
-rw-r--r--src/gui/widgets/progressbar.cpp7
-rw-r--r--src/gui/widgets/window.cpp71
3 files changed, 61 insertions, 32 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 97afec6d3..6d052b2b8 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -89,7 +89,7 @@ Skin::~Skin()
{
for (int i = 0; i < 9; i++)
{
- if (mBorder->grid[i])
+ if (mBorder && mBorder->grid[i])
{
mBorder->grid[i]->decRef();
mBorder->grid[i] = nullptr;
@@ -132,10 +132,13 @@ void Skin::updateAlpha(const float minimumOpacityAllowed)
std::max(static_cast<double>(minimumOpacityAllowed),
static_cast<double>(client->getGuiAlpha())));
- for (int i = 0; i < 9; i++)
+ if (mBorder)
{
- if (mBorder->grid[i])
- mBorder->grid[i]->setAlpha(alpha);
+ for (int i = 0; i < 9; i++)
+ {
+ if (mBorder->grid[i])
+ mBorder->grid[i]->setAlpha(alpha);
+ }
}
if (mCloseImage)
@@ -150,7 +153,7 @@ void Skin::updateAlpha(const float minimumOpacityAllowed)
int Skin::getMinWidth() const
{
- if (!mBorder->grid[ImageRect::UPPER_LEFT]
+ if (!mBorder || !mBorder->grid[ImageRect::UPPER_LEFT]
|| !mBorder->grid[ImageRect::UPPER_RIGHT])
{
return 1;
@@ -162,7 +165,7 @@ int Skin::getMinWidth() const
int Skin::getMinHeight() const
{
- if (!mBorder->grid[ImageRect::UPPER_LEFT]
+ if (!mBorder || !mBorder->grid[ImageRect::UPPER_LEFT]
|| !mBorder->grid[ImageRect::LOWER_LEFT])
{
return 1;
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 33e27a0d9..dc1e02ac5 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -71,8 +71,11 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
if (theme)
{
mSkin = theme->load("progressbar.xml", "");
- setPadding(mSkin->getPadding());
- mFillPadding = mSkin->getOption("fillPadding");
+ if (mSkin)
+ {
+ setPadding(mSkin->getPadding());
+ mFillPadding = mSkin->getOption("fillPadding");
+ }
setHeight(2 * mPadding + getFont()->getHeight() + 2);
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 38fd315fb..fccf8bbcd 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -458,8 +458,17 @@ void Window::setResizable(const bool r)
if (r)
{
mGrip = Theme::getImageFromThemeXml("resize.xml", "");
- mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
- mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
+ if (mGrip)
+ {
+ mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
+ mGripRect.y = mDimension.height - mGrip->getHeight()
+ - mGripPadding;
+ }
+ else
+ {
+ mGripRect.x = 0;
+ mGripRect.y = 0;
+ }
}
else
{
@@ -483,35 +492,49 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
int h = area.height;
mLayout->reflow(w, h);
}
- const bool showClose = mCloseButton && mSkin->getCloseImage(false);
- const int closePadding = getOption("closePadding");
- if (showClose)
- {
- const Image *const button = mSkin->getCloseImage(false);
- const int buttonWidth = button->getWidth();
- mCloseRect.x = mDimension.width - buttonWidth - closePadding;
- mCloseRect.y = closePadding;
- mCloseRect.width = buttonWidth;
- mCloseRect.height = button->getHeight();
- }
- if (mStickyButton)
+ if (mSkin)
{
- const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ const bool showClose = mCloseButton && mSkin->getCloseImage(false);
+ const int closePadding = getOption("closePadding");
+ if (showClose)
{
+ const Image *const button = mSkin->getCloseImage(false);
const int buttonWidth = button->getWidth();
- int x = mDimension.width - buttonWidth
- - getOption("stickySpacing") - closePadding;
+ mCloseRect.x = mDimension.width - buttonWidth - closePadding;
+ mCloseRect.y = closePadding;
+ mCloseRect.width = buttonWidth;
+ mCloseRect.height = button->getHeight();
+ }
+ if (mStickyButton)
+ {
+ const Image *const button = mSkin->getStickyImage(mSticky);
+ if (button)
+ {
+ const int buttonWidth = button->getWidth();
+ int x = mDimension.width - buttonWidth
+ - getOption("stickySpacing") - closePadding;
- if (showClose)
- x -= mSkin->getCloseImage(false)->getWidth();
+ if (showClose)
+ x -= mSkin->getCloseImage(false)->getWidth();
- mStickyRect.x = x;
- mStickyRect.y = getOption("stickyPadding");
- mStickyRect.width = buttonWidth;
- mStickyRect.height = button->getHeight();
+ mStickyRect.x = x;
+ mStickyRect.y = getOption("stickyPadding");
+ mStickyRect.width = buttonWidth;
+ mStickyRect.height = button->getHeight();
+ }
}
}
+ else
+ {
+ mCloseRect.x = 0;
+ mCloseRect.y = 0;
+ mCloseRect.width = 0;
+ mCloseRect.height = 0;
+ mStickyRect.x = 0;
+ mStickyRect.y = 0;
+ mStickyRect.width = 0;
+ mStickyRect.height = 0;
+ }
mRedraw = true;
}