laumaya / GLC_lib

GLC_lib is a C++ library for high performance 3D application based on OpenGL and Qt4 GUI
http://www.glc-lib.net
Other
61 stars 31 forks source link

Assert fires when deleting QGLWidget with 2+ GLC_context created #13

Open PhoenixBlack opened 11 years ago

PhoenixBlack commented 11 years ago

It seems that there's some problem when using multiple QGLContext's. What seems to happen is that GLC_ContextSharedData is deleted after GLC_Context is removed from list of contexts in GLC_ContextManager.

The destructor for QGLShader attempts to switch back to original context for removing the shader - but the context is already out of the GLC_ContextManager list, causing this assert to fire:

void GLC_ContextManager::setCurrent(GLC_Context* pContext)
{
    Q_ASSERT((NULL == pContext) || m_SetOfContext.contains(pContext)); //Fails: m_SetOfContext already doesn't contain pContext, even though it did a moment ago...
    m_pCurrentContext= pContext;
}

This obviously happens only with multiple GLC_Context, Qt doesn't try to switch anything when there's just one context.

Full call trace (from destroying the window, to going through GLC_Context destructor and finally deleting the shader in GLC_ContextSharedData.

>   foxworks_editord32.exe!fw_editor_message(QtMsgType type=QtFatalMsg, const char * msg=0x074e6740)  Line 68   C++
    QtCored4.dll!qt_message_output(QtMsgType msgType=QtFatalMsg, const char * buf=0x074e6740)  Line 2269 + 0xe bytes    C++
    QtCored4.dll!qt_message(QtMsgType msgType=QtFatalMsg, const char * msg=0x629c5e7c, char * ap=0x00b4b4a8)  Line 2369 + 0x12 bytes    C++
    QtCored4.dll!qFatal(const char * msg=0x629c5e7c, ...)  Line 2552 + 0xf bytes    C++
    QtCored4.dll!qt_assert(const char * assertion=0x0076ab68, const char * file=0x0076aaf4, int line=84)  Line 2018 + 0x16 bytes    C++
    foxworks_editord32.exe!GLC_ContextManager::setCurrent(GLC_Context * pContext=0x030a8cb0)  Line 84 + 0x38 bytes  C++
    foxworks_editord32.exe!GLC_Context::makeCurrent()  Line 260 C++
    QtOpenGLd4.dll!QGLShareContextScope::QGLShareContextScope(const QGLContext * ctx=0x030a8cb0)  Line 494  C++
    QtOpenGLd4.dll!QGLShaderProgramPrivate::~QGLShaderProgramPrivate()  Line 575 + 0x14 bytes   C++
    QtOpenGLd4.dll!QGLShaderProgramPrivate::`scalar deleting destructor'()  + 0xf bytes C++
    QtCored4.dll!QScopedPointerDeleter<QObjectData>::cleanup(QObjectData * pointer=0x03058eb8)  Line 62 + 0x20 bytes    C++
    QtCored4.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::~QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >()  Line 100 + 0x9 bytes  C++
    QtCored4.dll!QObject::~QObject()  Line 939 + 0x12 bytes C++
    QtOpenGLd4.dll!QGLShaderProgram::~QGLShaderProgram()  Line 623 + 0x9 bytes  C++
    foxworks_editord32.exe!GLC_Shader::~GLC_Shader()  Line 144 + 0xb2 bytes C++
    foxworks_editord32.exe!GLC_Shader::`scalar deleting destructor'()  + 0x2b bytes C++
    foxworks_editord32.exe!GLC_ContextSharedData::~GLC_ContextSharedData()  Line 69 + 0x2e bytes    C++
    foxworks_editord32.exe!GLC_ContextSharedData::`scalar deleting destructor'()  + 0x2b bytes  C++
    foxworks_editord32.exe!QtSharedPointer::ExternalRefCount<GLC_ContextSharedData>::deref(QtSharedPointer::ExternalRefCountData * d=0x030ac580, GLC_ContextSharedData * value=0x030abda8)  Line 342 + 0x34 bytes   C++
    foxworks_editord32.exe!QtSharedPointer::ExternalRefCount<GLC_ContextSharedData>::deref()  Line 336 + 0x35 bytes C++
    foxworks_editord32.exe!QtSharedPointer::ExternalRefCount<GLC_ContextSharedData>::~ExternalRefCount<GLC_ContextSharedData>()  Line 401 + 0x2b bytes  C++
    foxworks_editord32.exe!QSharedPointer<GLC_ContextSharedData>::~QSharedPointer<GLC_ContextSharedData>()  + 0x2b bytes    C++
    foxworks_editord32.exe!GLC_Context::~GLC_Context()  Line 44 + 0xf bytes C++
    foxworks_editord32.exe!GLC_Context::`scalar deleting destructor'()  + 0x2b bytes    C++
    QtOpenGLd4.dll!QGLWidget::~QGLWidget()  Line 3923 + 0x26 bytes  C++
    foxworks_editord32.exe!QGLWidget::`scalar deleting destructor'()  + 0x2e bytes  C++
    QtCored4.dll!QObjectPrivate::deleteChildren()  Line 1907 + 0x24 bytes   C++
    QtGuid4.dll!QWidget::~QWidget()  Line 1682  C++
    QtGuid4.dll!QFrame::~QFrame()  Line 242 + 0x8 bytes C++
    QtGuid4.dll!QAbstractScrollArea::~QAbstractScrollArea()  Line 526 + 0xf bytes   C++
    QtGuid4.dll!QGraphicsView::~QGraphicsView()  Line 1164 + 0xf bytes  C++
    foxworks_editord32.exe!EVDS::GLView::~GLView()  + 0x2e bytes    C++
    foxworks_editord32.exe!EVDS::GLView::`scalar deleting destructor'()  + 0x2b bytes   C++
    QtCored4.dll!QObjectPrivate::deleteChildren()  Line 1907 + 0x24 bytes   C++
    QtGuid4.dll!QWidget::~QWidget()  Line 1682  C++
    QtGuid4.dll!QMainWindow::~QMainWindow()  Line 389 + 0x22 bytes  C++
    foxworks_editord32.exe!EVDS::Editor::~Editor()  Line 156 + 0x58 bytes   C++
    foxworks_editord32.exe!EVDS::Editor::`scalar deleting destructor'()  + 0x2b bytes   C++
    QtCored4.dll!QObjectPrivate::deleteChildren()  Line 1907 + 0x24 bytes   C++
    QtGuid4.dll!QWidget::~QWidget()  Line 1682  C++
    foxworks_editord32.exe!QWidget::`scalar deleting destructor'()  + 0x2e bytes    C++
    QtCored4.dll!QObjectPrivate::deleteChildren()  Line 1907 + 0x24 bytes   C++
    QtGuid4.dll!QWidget::~QWidget()  Line 1682  C++
    QtGuid4.dll!QMainWindow::~QMainWindow()  Line 389 + 0x22 bytes  C++
    foxworks_editord32.exe!ChildWindow::~ChildWindow()  + 0x70 bytes    C++
PhoenixBlack commented 11 years ago

Is there any way to make GLC_ContextSharedData be destroyed BEFORE GLC_Context? Does that make sense at all?