mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 12:12:32 +02:00
Merge pull request #8275 from jherico/web_entity_leak
Cleanup resources used by offscreen GL surfaces
This commit is contained in:
commit
2e491e0afb
4 changed files with 20 additions and 9 deletions
|
@ -36,7 +36,15 @@ OffscreenGLCanvas::~OffscreenGLCanvas() {
|
||||||
delete _logger;
|
delete _logger;
|
||||||
_logger = nullptr;
|
_logger = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
_context->doneCurrent();
|
_context->doneCurrent();
|
||||||
|
delete _context;
|
||||||
|
_context = nullptr;
|
||||||
|
|
||||||
|
_offscreenSurface->destroy();
|
||||||
|
delete _offscreenSurface;
|
||||||
|
_offscreenSurface = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
||||||
|
|
|
@ -34,8 +34,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::once_flag _reportOnce;
|
std::once_flag _reportOnce;
|
||||||
QOpenGLContext* _context;
|
QOpenGLContext* _context{ nullptr };
|
||||||
QOffscreenSurface* _offscreenSurface;
|
QOffscreenSurface* _offscreenSurface{ nullptr };
|
||||||
QOpenGLDebugLogger* _logger{ nullptr };
|
QOpenGLDebugLogger* _logger{ nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,17 @@ QOpenGLContext* QOpenGLContextWrapper::currentContext() {
|
||||||
return QOpenGLContext::currentContext();
|
return QOpenGLContext::currentContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QOpenGLContextWrapper::QOpenGLContextWrapper() :
|
QOpenGLContextWrapper::QOpenGLContextWrapper() :
|
||||||
_context(new QOpenGLContext)
|
_ownContext(true), _context(new QOpenGLContext) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QOpenGLContextWrapper::QOpenGLContextWrapper(QOpenGLContext* context) :
|
QOpenGLContextWrapper::QOpenGLContextWrapper(QOpenGLContext* context) :
|
||||||
_context(context)
|
_context(context) { }
|
||||||
{
|
|
||||||
|
QOpenGLContextWrapper::~QOpenGLContextWrapper() {
|
||||||
|
if (_ownContext) {
|
||||||
|
delete _context;
|
||||||
|
_context = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QOpenGLContextWrapper::setFormat(const QSurfaceFormat& format) {
|
void QOpenGLContextWrapper::setFormat(const QSurfaceFormat& format) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ class QOpenGLContextWrapper {
|
||||||
public:
|
public:
|
||||||
QOpenGLContextWrapper();
|
QOpenGLContextWrapper();
|
||||||
QOpenGLContextWrapper(QOpenGLContext* context);
|
QOpenGLContextWrapper(QOpenGLContext* context);
|
||||||
|
virtual ~QOpenGLContextWrapper();
|
||||||
void setFormat(const QSurfaceFormat& format);
|
void setFormat(const QSurfaceFormat& format);
|
||||||
bool create();
|
bool create();
|
||||||
void swapBuffers(QSurface* surface);
|
void swapBuffers(QSurface* surface);
|
||||||
|
@ -40,6 +41,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool _ownContext { false };
|
||||||
QOpenGLContext* _context { nullptr };
|
QOpenGLContext* _context { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue