1
0
forked from 0ad/0ad

Fix a crash on some system when Alt-tabbing during game setup.

Move checks for rendering a frame in Render() to avoid missing calls to
this functions, which can crash on certain systems.

Move the sound manager's idle task out of Render().
Move the buffer swapping in Render() since we do not need to swap
buffers unless we are rendering.

Patch By: Angen
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D1495
This was SVN commit r22314.
This commit is contained in:
wraitii 2019-05-28 13:18:32 +00:00
parent 0c20afdfda
commit ca9109be75
2 changed files with 18 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -79,6 +79,7 @@ that of Atlas depending on commandline parameters.
#include "scriptinterface/ScriptEngine.h"
#include "simulation2/Simulation2.h"
#include "simulation2/system/TurnManager.h"
#include "soundmanager/ISoundManager.h"
#if OS_UNIX
#include <unistd.h> // geteuid
@ -407,16 +408,10 @@ static void Frame()
g_Console->Update(realTimeSinceLastFrame);
ogl_WarnIfError();
// We do not have to render an inactive fullscreen frame, because it can
// lead to errors for some graphic card families.
if (!g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen()))
{
Render();
if (g_SoundManager)
g_SoundManager->IdleTask();
PROFILE3("swap buffers");
SDL_GL_SwapWindow(g_VideoMode.GetWindow());
}
ogl_WarnIfError();
Render();
g_Profiler.Frame();

View File

@ -188,14 +188,21 @@ void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task)
g_GUI->GetActiveGUI()->SendEventToAll("progress");
}
void SwapBuffers()
{
PROFILE3("swap buffers");
SDL_GL_SwapWindow(g_VideoMode.GetWindow());
ogl_WarnIfError();
}
void Render()
{
PROFILE3("render");
// Do not render if not focused while in fullscreen or minimised,
// as that triggers a difficult-to-reproduce crash on some graphic cards.
if (g_app_minimized || (!g_app_has_focus && g_VideoMode.IsInFullscreen()))
return;
if (g_SoundManager)
g_SoundManager->IdleTask();
PROFILE3("render");
ogl_WarnIfError();
@ -330,6 +337,8 @@ void Render()
g_Profiler2.RecordGPUFrameEnd();
ogl_WarnIfError();
SwapBuffers();
}
ErrorReactionInternal psDisplayError(const wchar_t* UNUSED(text), size_t UNUSED(flags))