From fbcfa27edf518835976e140ec160db009186bc16 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 28 Apr 2012 13:47:32 +0300 Subject: Fix code style and add some checks. --- src/resources/image.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/resources') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 274262304..fa9f1462a 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -940,10 +940,20 @@ SubImage::SubImage(Image *parent, GLuint image, mBounds.y = static_cast(y); mBounds.w = static_cast(width); mBounds.h = static_cast(height); - mInternalBounds.x = mParent->mBounds.x; - mInternalBounds.y = mParent->mBounds.y; - mInternalBounds.w = mParent->mBounds.w; - mInternalBounds.h = mParent->mBounds.h; + if (mParent) + { + mInternalBounds.x = mParent->mBounds.x; + mInternalBounds.y = mParent->mBounds.y; + mInternalBounds.w = mParent->mBounds.w; + mInternalBounds.h = mParent->mBounds.h; + } + else + { + mInternalBounds.x = 0; + mInternalBounds.y = 0; + mInternalBounds.w = 1; + mInternalBounds.h = 1; + } mIsAlphaVisible = mHasAlphaChannel; } #endif -- cgit v1.2.3-70-g09d2