mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
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:
parent
7ab377f28e
commit
f989bce584
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user