adspartan :
noggit: application: add failsafe for when the opengl context creatio…
…n get stuck
3e4f41e158
This commit is contained in:
@@ -57,7 +57,7 @@ MapChunk::MapChunk(MapTile* maintile, BlizzardArchive::ClientFile* f, bool bigAl
|
||||
// xbase = header.xpos;
|
||||
// ybase = header.ypos;
|
||||
|
||||
texture_set = nullptr;
|
||||
texture_set.reset();
|
||||
|
||||
auto& tile_buffer = mt->getChunkHeightmapBuffer();
|
||||
int chunk_start = (px * 16 + py) * mapbufsize * 4;
|
||||
|
||||
@@ -115,7 +115,7 @@ std::vector<std::tuple<int, int, int>> ModelInstance::intersect (glm::mat4x4 con
|
||||
|
||||
bool ModelInstance::isInFrustum(const math::frustum& frustum)
|
||||
{
|
||||
if (_need_recalc_extents && model->finishedLoading())
|
||||
if (_need_recalc_extents)
|
||||
{
|
||||
recalcExtents();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,35 @@
|
||||
#include <noggit/project/ApplicationProject.h>
|
||||
#include <noggit/Log.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
#include <thread>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::atomic_bool success = false;
|
||||
|
||||
void opengl_context_creation_stuck_failsafe()
|
||||
{
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
if (success.load())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LogError << "OpenGL Context creation failed (timeout), closing..." << std::endl;
|
||||
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
namespace Noggit::Application
|
||||
{
|
||||
void NoggitApplication::initalize(int argc, char* argv[], std::vector<bool> Parser)
|
||||
@@ -163,6 +188,10 @@ namespace Noggit::Application
|
||||
bool doAntiAliasing = app_settings.value("anti_aliasing", false).toBool();
|
||||
format.setSamples(doAntiAliasing ? 4 : applicationConfiguration.GraphicsConfiguration.SamplesCount); // default is 0, no AA
|
||||
|
||||
// context creation seems to get stuck sometimes, this ensure the app is killed
|
||||
// otherwise it's wasting cpu resources and is annoying when developping
|
||||
auto failsafe = std::async(&opengl_context_creation_stuck_failsafe);
|
||||
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
QOpenGLContext context;
|
||||
context.create();
|
||||
@@ -172,6 +201,8 @@ namespace Noggit::Application
|
||||
|
||||
context.makeCurrent(&surface);
|
||||
|
||||
success = true;
|
||||
|
||||
OpenGL::context::scoped_setter const _(::gl, &context);
|
||||
|
||||
GLint majVers = 0, minVers = 0;
|
||||
|
||||
Reference in New Issue
Block a user