PDA

View Full Version : Problem combining QWorkspace & QGLWidget



Nb2Qt
18th December 2006, 20:18
I'm getting infinately increasing memory usage and GDI handle usage whenever I dynamically create QGLWidgets and add them to a QWorkspace. Interestingly, the leak only happens when I'm using a QTimer to drive the animation *and* only after a 2nd widget is created. No leaks occur with only 1 gl widget created. Eventually the computer will freak out (after thousands of GDI handles are allocated).

I've narrowed the problem down to a bare minimum:
- create a QMainWindow
- set a QWorkspace as the centralWidget()
- add menu item to create a new instance of your QGLWidget
- the menu action creates a new GLWidget and uses the workspace's addWindow() function.
- a QTimer is used (either in the QMainWindow or the GLWidget itself...doesn't matter) to drive the animation.

Running the program and using the menu item to create new GLWidgets appears to work fine. New windows appear, each with unque instance of my GLWidget. However, after a 2nd window has been created, memory and GDI handles start getting allocated at regular intervals (implying a timer'd function) and never deallocated. I've stepped through the code and all things point to a Qt problem.

Interestingly, the problem *does not happen* if I use anything other than a QWorkspace. So doing setCentralWidget(new QWidget) and then setting the layout to a QHBoxLayout does not show the same bad behavior.

Any ideas? I'm stumped. I have example code it needed. Thanks.

-Rob

wysota
18th December 2006, 21:45
What things point to a Qt problem?