Error message "create: CreateWindowEx failed"
-
Hello,
I have a really simple code which looks like this :
class myView : public QWidget { Q_OBJECT public: myView() { mView = new QGraphicsView(); setWidget(mView); QGraphicsScene * scene = new QGraphicsScene(); mView.setScene(scene); } void updateView() { QGraphicsScene * oldScene = mView->scene(); QGraphicsScene * newScene = new QGraphicsScene(); // I add different widgets and graphicsWidgets in the newScene depending on my model mView->setScene(newScene); oldScene->deleteLater(); } private: QGraphicsView * mView = nullptr; }
The idea is that I have different widgets and graphicsWidgets in the 'newScene'. I have connected user interaction with a signal which is received by an object containing the object myView. A computation is done to modify the model and my view is updated through 'updateView'. The processing chain is : clickOnWidget -> signal to model -> model update -> update view with 'updateView'.
I works well many times but, after different calls to 'updateView', I get a segfault with the following message I do not understand :
create: CreateWindowEx failed (Le processus actuel a utilisé tout son lot alloué par le système de descripteurs pour les objets du Gestionnaire de fenêtre.) Failed to create platform window for QWidgetWindow(0x1f031f60, name="QLabelClassWindow") with flags QFlags<Qt::WindowType>(Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint)
Do you have any idea about what could be the source of this segfault ? Thanks in advance !
-
Hi,
What version of Qt are you using ?
On what version of Windows ? -
Do you check with a more recent version of Qt ?
-
I have tried 3 differents approaches (because I really do not understand the error message) :
- first: use a single scene with clear() function (I think it is @JonB solution). It crashed so I though it was related to a possible late call to a cleared object
- second, I tried @hskoglund solution using 'delete'. Since I got same crash, I tried a third option
- third: use a deleteLater
If it helps, the probability to crash is far higher when there is a large number of items in the scene (quite no crash with around 100 items but regular crash with about 1000 items)
-
Well, firstly you'll never get a
CreateWindowEx
error under Linux because that is the name of a native Windows(-only) function for creating a window!create: CreateWindowEx failed (Le processus actuel a utilisé tout son lot alloué par le système de descripteurs pour les objets du Gestionnaire de fenêtre.)
This almost certainly means that you have exceeded the number of "Window Manager objects" allowed, Windows has run out of handles. That will be why it "works well many times", till the maximum gets exceeded.
As we have said before, the "best guess" would be that you are failing to delete/leaking window handles somewhere.
Under Windows there are external tools (you'll have to Google) for examining what windows/objects/handles are in use by Windows. You might that useful.
-
Interesting comment @JonB. I do not create any new window in this process but I have sub-classed QDockWidget to carry my view (called "myView" in my exemple). Here is the code (to avoid closing a QDockWidget with ALT+F4):
#include "uncloseableDockWidget.h" #include <QCloseEvent> uncloseableDockWidget::uncloseableDockWidget(const QString & title, QWidget * parent, Qt::WindowFlags flags) : QDockWidget(title, parent, flags) { setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); setAllowedAreas(Qt::AllDockWidgetAreas); } uncloseableDockWidget::~uncloseableDockWidget() { } void uncloseableDockWidget::closeEvent(QCloseEvent * event) { event->ignore(); }
Could the closeEvent interact with something in my view. I do not see direct link but as you explain that I could have not deleted something, it rings my bell !
-
@Julieng
It doesn't shout at me. Remove to test?The idea is that I have different widgets and graphicsWidgets in the 'newScene'.
Every
QWidget
you create will have a Windows windowCreateWindowEx
. I don't know about your "graphicsWidgets ". I'm thinking you are creating a "large" number of these. That would happen if you're are not destroying them, for whatever reason. I'm thinking the error message is pretty severe!create: CreateWindowEx failed (Le processus actuel a utilisé tout son lot alloué par le système de descripteurs pour les objets du Gestionnaire de fenêtre.)
Google to find the correct corresponding English error message. Then Google for that. Find out why it would be issued. There must be tool to show how many windows have been created by a process or in the system as a whole, and see if that is indeed "large". Look for you using up all of them!
-
Hi,
The error states that you exhausted all the available descriptors for objects of the window manager. Any chances you are leaking widgets or other graphical components ?
-
@Julieng
@SGaist has confirmed what I suggested --- you must surely(?) be leaking widgets somewhere in your code, causing Windows to run out of windows(!). The fact that you reportedclear()
crashed, anddelete
crashed, anddeleteLater()
crashed after a while must be indicating something is awry.For widgets only (unfortunately), for debugging "orphanages" I use https://doc.qt.io/qt-5/qapplication.html#allWidgets. You can walk that to see what's in existence, or has no parent. Even if all you do is examine its length at an appropriate point in your code, if there are a "large number" there when there shouldn't be it shows you have some leak....
For
QObject
-derived classes (includingQWidget
) you can slot onto the https://doc.qt.io/qt-5/qobject.html#destroyed signal. If you simply count there, if you create 1,000QObject
s but don't see that many destroyed, you're leaking.For your
QGraphicsItem
s unfortunately neither of these techniques apply. I'm not sure if they can ever get orphaned from aQGraphicsScene
. Though creating aQGraphicsItem(nullptr)
and then failing to callQGraphicsScene::addItem()
would leave it dangling, as would callingQGraphicsScene::removeItem()
and then not deleting it yourself afterward. Some food for thought.