summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-01-26 20:10:12 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-01-26 22:34:10 +0100
commitfed093879282fac03c4fdcaa0aac519de468f1e1 (patch)
tree1043129fb0c1e21b626c1e7809b44c43f6837d7b
parent7ada762ca81045cfe8b2556ae9e7b8b4749d84f8 (diff)
downloadmana-client-fed093879282fac03c4fdcaa0aac519de468f1e1.tar.gz
mana-client-fed093879282fac03c4fdcaa0aac519de468f1e1.tar.bz2
mana-client-fed093879282fac03c4fdcaa0aac519de468f1e1.tar.xz
mana-client-fed093879282fac03c4fdcaa0aac519de468f1e1.zip
Fixed crash when failing to switch to fullscreen/windowed
The setup page tries to restore the previous video mode by calling setFullscreen again after it has failed. However, the setFullscreen function assumed a valid mode was set (it referenced mScreen). This would then crash. Worked around by remembering the parameters passed to setVideoMode, and using those in setFullscreen. Besides fixing a potential crash, this also fixes switching between fullscreen and windowed on Maemo 5. Probably trying to keep the color depth the same was what made it fail (which is not necessary anyway).
-rw-r--r--src/graphics.cpp21
-rw-r--r--src/graphics.h6
2 files changed, 19 insertions, 8 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 14a2b852..f7f49e81 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -28,7 +28,12 @@
#include "resources/imageloader.h"
Graphics::Graphics():
- mScreen(0)
+ mScreen(0),
+ mWidth(0),
+ mHeight(0),
+ mBpp(0),
+ mFullscreen(false),
+ mHWAccel(false)
{
}
@@ -46,6 +51,9 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
int displayFlags = SDL_ANYFORMAT;
+ mWidth = w;
+ mHeight = h;
+ mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
@@ -101,18 +109,17 @@ bool Graphics::setFullscreen(bool fs)
if (mFullscreen == fs)
return true;
- return setVideoMode(mScreen->w, mScreen->h,
- mScreen->format->BitsPerPixel, fs, mHWAccel);
+ return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel);
}
int Graphics::getWidth() const
{
- return mScreen->w;
+ return mWidth;
}
int Graphics::getHeight() const
{
- return mScreen->h;
+ return mHeight;
}
bool Graphics::drawImage(Image *image, int x, int y)
@@ -163,8 +170,8 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
int width, int height, bool)
{
// Check that preconditions for blitting are met.
- if (!mScreen || !image) return false;
- if (!image->mSDLSurface) return false;
+ if (!mScreen || !image || !image->mSDLSurface)
+ return false;
dstX += mClipStack.top().xOffset;
dstY += mClipStack.top().yOffset;
diff --git a/src/graphics.h b/src/graphics.h
index b8e87af1..b9b2b1d5 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -195,7 +195,11 @@ class Graphics : public gcn::SDLGraphics
protected:
SDL_Surface *mScreen;
- bool mFullscreen, mHWAccel;
+ int mWidth;
+ int mHeight;
+ int mBpp;
+ bool mFullscreen;
+ bool mHWAccel;
};
extern Graphics *graphics;