wgldisplay: don't restore gamma atexit if we never modified it

This avoids possible instability (see #685) when this feature isn't even used
This commit is contained in:
rdb 2019-07-29 17:04:30 +02:00
parent 7ab377f28e
commit f989bce584

View File

@ -16,6 +16,7 @@
#include "wglGraphicsBuffer.h"
#include "wglGraphicsPipe.h"
#include "string_utils.h"
#include <atomic>
TypeHandle wglGraphicsStateGuardian::_type_handle;
@ -49,7 +50,6 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
_wglCreateContextAttribsARB = nullptr;
get_gamma_table();
atexit(atexit_function);
}
/**
@ -886,6 +886,12 @@ static_set_gamma(bool restore, PN_stdfloat gamma) {
if (SetDeviceGammaRamp (hdc, ramp)) {
set = true;
// Register an atexit handler
static std::atomic_flag gamma_modified = ATOMIC_FLAG_INIT;
if (!gamma_modified.test_and_set()) {
atexit(atexit_function);
}
}
ReleaseDC (nullptr, hdc);