mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- fixed potential crash on fatal error in Cocoa backend
Early fatal error can be triggered when native OpenGL frame buffer is not created yet and DDummyFrameBuffer is still used
This commit is contained in:
parent
8ac864b007
commit
1ebc169d56
1 changed files with 14 additions and 14 deletions
|
@ -319,6 +319,9 @@ NSOpenGLPixelFormat* CreatePixelFormat(const NSOpenGLPixelFormatAttribute profil
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
static SystemGLFrameBuffer* frameBuffer;
|
||||
|
||||
|
||||
SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
|
||||
: DFrameBuffer(vid_defwidth, vid_defheight)
|
||||
, m_window(CreateWindow(STYLE_MASK_WINDOWED))
|
||||
|
@ -383,6 +386,8 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
|
|||
}
|
||||
}
|
||||
|
||||
frameBuffer = this;
|
||||
|
||||
FConsoleWindow::GetInstance().Show(false);
|
||||
}
|
||||
|
||||
|
@ -532,24 +537,19 @@ void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
|
|||
}
|
||||
|
||||
|
||||
static SystemGLFrameBuffer* GetSystemFrameBuffer()
|
||||
{
|
||||
return static_cast<SystemGLFrameBuffer*>(screen);
|
||||
}
|
||||
|
||||
void SystemGLFrameBuffer::UseHiDPI(const bool hiDPI)
|
||||
{
|
||||
if (auto fb = GetSystemFrameBuffer())
|
||||
if (frameBuffer != nullptr)
|
||||
{
|
||||
fb->SetMode(fb->m_fullscreen, hiDPI);
|
||||
frameBuffer->SetMode(frameBuffer->m_fullscreen, hiDPI);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
|
||||
{
|
||||
if (auto fb = GetSystemFrameBuffer())
|
||||
if (frameBuffer != nullptr)
|
||||
{
|
||||
NSWindow* const window = fb->m_window;
|
||||
NSWindow* const window = frameBuffer->m_window;
|
||||
CocoaView* const view = [window contentView];
|
||||
|
||||
[view setCursor:cursor];
|
||||
|
@ -559,15 +559,15 @@ void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
|
|||
|
||||
void SystemGLFrameBuffer::SetWindowVisible(bool visible)
|
||||
{
|
||||
if (auto fb = GetSystemFrameBuffer())
|
||||
if (frameBuffer != nullptr)
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
[fb->m_window orderFront:nil];
|
||||
[frameBuffer->m_window orderFront:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fb->m_window orderOut:nil];
|
||||
[frameBuffer->m_window orderOut:nil];
|
||||
}
|
||||
|
||||
I_SetNativeMouse(!visible);
|
||||
|
@ -576,11 +576,11 @@ void SystemGLFrameBuffer::SetWindowVisible(bool visible)
|
|||
|
||||
void SystemGLFrameBuffer::SetWindowTitle(const char* title)
|
||||
{
|
||||
if (auto fb = GetSystemFrameBuffer())
|
||||
if (frameBuffer != nullptr)
|
||||
{
|
||||
NSString* const nsTitle = nullptr == title ? nil :
|
||||
[NSString stringWithCString:title encoding:NSISOLatin1StringEncoding];
|
||||
[fb->m_window setTitle:nsTitle];
|
||||
[frameBuffer->m_window setTitle:nsTitle];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue