Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Segfault when connect cleanup OpenGL function to signal QOpenGLContext::aboutToBeDestroyed
Forum Updated to NodeBB v4.3 + New Features

Segfault when connect cleanup OpenGL function to signal QOpenGLContext::aboutToBeDestroyed

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 463 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dalishi
    wrote on last edited by dalishi
    #1

    Hi I am using the QOpenGLWidget of Qt 5.9.2 on Ubuntu16.04. Using the following connect() to clean up OpenGL buffer objects but get segment fault when destroy buffer objects. So I ended up putting cleanup() in the destructor. I remembered this signal ::aboutToBeDestroyed is recommended to do cleanup to the destructor but why it does not work now.

    Does not work:

    connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &MainOpenGLWidget::cleanup);
    
    void MainOpenGLWidget::cleanup()
    {
        makeCurrent();
    
        if (m_program)
        {
            delete m_program;
            m_program = 0;
        }
    
        if (m_vboPos.isCreated())
            m_vboPos.destroy(); // Segfault here
    
        if (m_vboCol.isCreated())
            m_vboCol.destroy();
    
        if (m_vao.isCreated())
            m_vao.destroy();
    
        doneCurrent();
    }
    

    This works:

    MainOpenGLWidget::~MainOpenGLWidget()
    {
        cleanup();
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved