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. Error message "create: CreateWindowEx failed"

Error message "create: CreateWindowEx failed"

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 2.2k Views
  • 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.
  • J Julieng

    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 !

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #7

    @Julieng
    I am interested: why do you create a newly allocated scene and delete the current one, why not just clear out the current one and add your new stuff into it? I am a graphics beginner.

    1 Reply Last reply
    1
    • J Offline
      J Offline
      Julieng
      wrote on last edited by Julieng
      #8

      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)

      JonBJ 1 Reply Last reply
      0
      • J Julieng

        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)

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #9

        @Julieng
        Sounds like the deleteLater reduces the frequency of the problem but still is not right. I think I'd worry first about why clear() and re-use does not work. But then I did say I'm a beginner, so I don't know!

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Julieng
          wrote on last edited by
          #10

          I just tried it on Linux (Ubuntu 19.10) and I have no issue.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Julieng
            wrote on last edited by
            #11

            Tested today with a Qt 5.12 on Windows and I still have the issue. Any ideas about how to avoid this issue ? Thanks.

            1 Reply Last reply
            0
            • JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #12

              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.

              1 Reply Last reply
              1
              • J Offline
                J Offline
                Julieng
                wrote on last edited by Julieng
                #13

                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 !

                JonBJ 2 Replies Last reply
                0
                • J Julieng

                  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 !

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #14

                  @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 window CreateWindowEx. 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!

                  1 Reply Last reply
                  1
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #15

                    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 ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • J Julieng

                      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 !

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #16

                      @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 reported clear() crashed, and delete crashed, and deleteLater() 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 (including QWidget) you can slot onto the https://doc.qt.io/qt-5/qobject.html#destroyed signal. If you simply count there, if you create 1,000 QObjects but don't see that many destroyed, you're leaking.

                      For your QGraphicsItems unfortunately neither of these techniques apply. I'm not sure if they can ever get orphaned from a QGraphicsScene. Though creating a QGraphicsItem(nullptr) and then failing to call QGraphicsScene::addItem() would leave it dangling, as would calling QGraphicsScene::removeItem() and then not deleting it yourself afterward. Some food for thought.

                      1 Reply Last reply
                      1
                      • J Offline
                        J Offline
                        Julieng
                        wrote on last edited by
                        #17

                        @SGaist and @JonB , thanks a lot for your help ! I have used 'QApplication::allWidgets().size()' to track where I am leaking and indeed, I was generating lots of widgets from call to call. That's solved.

                        JonBJ 1 Reply Last reply
                        1
                        • J Julieng

                          @SGaist and @JonB , thanks a lot for your help ! I have used 'QApplication::allWidgets().size()' to track where I am leaking and indeed, I was generating lots of widgets from call to call. That's solved.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #18

                          @Julieng
                          Yay! QApplication::allWidgets() is my favorite QWidgets function :) I have a debugging function which walks them via parent, reporting on all those which are top-level orphaned even if they compose a tree.

                          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