Browse Source

GL: repro case for destructing a moved-out Mesh with no context active.

Boom! About time I fix this utter embarrassment.
pull/168/head
Vladimír Vondruš 2 years ago
parent
commit
9f67d4fd5b
  1. 22
      src/Magnum/GL/Test/MeshGLTest.cpp

22
src/Magnum/GL/Test/MeshGLTest.cpp

@ -26,6 +26,7 @@
#include <sstream>
#include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
@ -66,6 +67,8 @@ struct MeshGLTest: OpenGLTester {
void constructMove();
void wrap();
void destructMovedOutInstance();
template<class T> void primitive();
#ifndef MAGNUM_TARGET_WEBGL
@ -552,6 +555,8 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::constructMove,
&MeshGLTest::wrap,
&MeshGLTest::destructMovedOutInstance,
&MeshGLTest::primitive<GL::MeshPrimitive>,
&MeshGLTest::primitive<Magnum::MeshPrimitive>,
@ -913,6 +918,23 @@ void MeshGLTest::wrap() {
#endif
}
void MeshGLTest::destructMovedOutInstance() {
{
Containers::ScopeGuard restoreCurrentContext{&GL::Context::current(), GL::Context::makeCurrent};
Mesh a = Mesh::wrap(0xabcd);
CORRADE_COMPARE(a.id(), 0xabcd);
a = Mesh{NoCreate};
CORRADE_COMPARE(a.id(), 0);
GL::Context::makeCurrent(nullptr);
}
/* It shouldn't try to access the current context to decide anything */
CORRADE_VERIFY(true);
}
template<class T> void MeshGLTest::primitive() {
setTestCaseTemplateName(std::is_same<T, MeshPrimitive>::value ?
"GL::MeshPrimitive" : "Magnum::MeshPrimitive");

Loading…
Cancel
Save