Commit 7f644d03 authored by hybrid's avatar hybrid

Window size fix by Auria. For now we simply check for any error during window...

Window size fix by Auria. For now we simply check for any error during window creation and bail out safely. This avoids uncontrolled crashes of the app and may be handled by the app logic somehow.
Reordered some of the device attributes and ensured initialization of all values.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3966 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9d3c6302
...@@ -228,18 +228,18 @@ namespace irr ...@@ -228,18 +228,18 @@ namespace irr
NSWindow *Window; NSWindow *Window;
CGLContextObj CGLContext; CGLContextObj CGLContext;
NSOpenGLContext *OGLContext; NSOpenGLContext *OGLContext;
int DeviceWidth,
DeviceHeight;
std::map<int,int> KeyCodes;
int ScreenWidth,
ScreenHeight;
bool IsActive;
NSBitmapImageRep *SoftwareDriverTarget; NSBitmapImageRep *SoftwareDriverTarget;
bool IsSoftwareRenderer, std::map<int,int> KeyCodes;
IsShiftDown, int DeviceWidth;
IsControlDown, int DeviceHeight;
IsResizable; int ScreenWidth;
int ScreenHeight;
u32 MouseButtonStates; u32 MouseButtonStates;
bool IsActive;
bool IsSoftwareRenderer;
bool IsShiftDown;
bool IsControlDown;
bool IsResizable;
}; };
......
...@@ -472,9 +472,11 @@ namespace irr ...@@ -472,9 +472,11 @@ namespace irr
{ {
//! constructor //! constructor
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), Window(NULL), IsActive(true), OGLContext(NULL), CGLContext(NULL), : CIrrDeviceStub(param), Window(NULL), CGLContext(NULL), OGLContext(NULL),
SoftwareDriverTarget(0), IsSoftwareRenderer(false), IsResizable(false), SoftwareDriverTarget(0), DeviceWidth(0), DeviceHeight(0),
IsShiftDown(false), IsControlDown(false), MouseButtonStates(0) ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0),
IsActive(true), IsSoftwareRenderer(false),
IsShiftDown(false), IsControlDown(false), IsResizable(false)
{ {
struct utsname name; struct utsname name;
NSString *path; NSString *path;
...@@ -506,14 +508,16 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) ...@@ -506,14 +508,16 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
os::Printer::log(name.version,ELL_INFORMATION); os::Printer::log(name.version,ELL_INFORMATION);
initKeycodes(); initKeycodes();
bool success = true;
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
createWindow(); success = createWindow();
// in case of failure, one can check VideoDriver for initialization
if (!success)
return;
setResizable(false); setResizable(false);
CursorControl = new CCursorControl(CreationParams.WindowSize, this); CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver(); createDriver();
createGUIAndScene(); createGUIAndScene();
} }
...@@ -592,6 +596,10 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -592,6 +596,10 @@ bool CIrrDeviceMacOSX::createWindow()
VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight)); VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight));
// we need to check where the exceptions may happen and work at them
// for now we will just catch them to be able to avoid an app exit
@try
{
if (!CreationParams.Fullscreen) if (!CreationParams.Fullscreen)
{ {
if(!CreationParams.WindowId) //create another window when WindowId is null if(!CreationParams.WindowId) //create another window when WindowId is null
...@@ -757,6 +765,12 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -757,6 +765,12 @@ bool CIrrDeviceMacOSX::createWindow()
} }
} }
} }
}
@catch (NSException *exception)
{
// FIXME: cleanup may be needed here
result = false;
}
if (result) if (result)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment