I have such a code:
Qt Code:
  1. static QList<display_list*> displayLists;
To copy to clipboard, switch view to plain text mode 
items are added this way:
Qt Code:
  1. list = new display_list();
  2. list->new_list(GL_COMPILE);
  3. glBegin(GL_QUADS);
  4. ...
  5. glEnd();
  6. list->end_list();
  7. displayLists.append(list);
To copy to clipboard, switch view to plain text mode 
The problem is if I need to clear list and generate otehr display lists than displayLists.clear() is a bad choice - ~display_list() is not called for elements, in fact lists still reside in OpenGL memory. Currently I have such a header in function, that generates this list:
Qt Code:
  1. void prepareLists()
  2. {
  3. if(!displayLists.isEmpty())
  4. foreach(display_list* ptr, displayLists) delete ptr;
  5. displayLists.clear();
  6. ...
To copy to clipboard, switch view to plain text mode 
but I don't like it
Any ideas how to make it nice&clean?

PS: display_list is not a QObject