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. comboBox->additem() crash application..
Forum Updated to NodeBB v4.3 + New Features

comboBox->additem() crash application..

Scheduled Pinned Locked Moved Solved General and Desktop
27 Posts 6 Posters 5.2k Views 2 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.
  • VRoninV VRonin

    in the constructor of your class, can you add QObject::connect(ui->comboBox_Cliente,&Qobject::destroyed,[]()->void{qDebug("Something exploded");});?

    If you see the output it means you are deleting your ui before reusing it

    VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #12

    @VRonin said in comboBox->additem() crash application..:

    in the constructor of your class

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    TheCipo76T 1 Reply Last reply
    0
    • VRoninV VRonin

      @VRonin said in comboBox->additem() crash application..:

      in the constructor of your class

      TheCipo76T Offline
      TheCipo76T Offline
      TheCipo76
      wrote on last edited by TheCipo76
      #13

      @VRonin ok..

      no output were showed

      i've put it after

      ui->setupUi(this);
      

      in the dialog

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #14

        And it still crashes? did you set Qt::WA_DeleteOnClose?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        TheCipo76T 1 Reply Last reply
        0
        • VRoninV VRonin

          And it still crashes? did you set Qt::WA_DeleteOnClose?

          TheCipo76T Offline
          TheCipo76T Offline
          TheCipo76
          wrote on last edited by
          #15

          @VRonin No, i don't know what is it.. sorry but i'm new user of Qt

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #16

            One more try, add QObject::connect(this,&QObject::destroyed,[]()->void{qDebug("Something big exploded");}); and see if you have any output when you crash the application

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            TheCipo76T 1 Reply Last reply
            0
            • VRoninV VRonin

              One more try, add QObject::connect(this,&QObject::destroyed,[]()->void{qDebug("Something big exploded");}); and see if you have any output when you crash the application

              TheCipo76T Offline
              TheCipo76T Offline
              TheCipo76
              wrote on last edited by
              #17

              @VRonin said in comboBox->additem() crash application..:

              QObject::connect(this,&QObject::destroyed,->void{qDebug("Something big exploded");});

              no, i don't see any output..

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #18

                This is turning into a mistery now. Can you post the stack trace at the moment of crash?

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                TheCipo76T 1 Reply Last reply
                2
                • TheCipo76T TheCipo76

                  @Cobra91151

                  in application output :

                  18:45:34: The process was ended forcefully.
                  18:45:34: /Users/matteo/Desktop/C++/QT/EasyGest/build-EasyGest-Desktop_Qt_5_11_2_clang_64bit18-Release/EasyGest.app/Contents/MacOS/EasyGest crashed.

                  Cobra91151C Offline
                  Cobra91151C Offline
                  Cobra91151
                  wrote on last edited by Cobra91151
                  #19

                  @TheCipo76

                  This crash happens after you addItem() to the ui->comboBox_Cliente?

                  Try to change the code to:

                  if (cl.exec()) {
                      msg.setText("QUI");
                      msg.exec();
                  
                      if (cl.first()) {
                           msg.setText("OK");
                           msg.exec();
                      }
                  
                      do {
                          ui->comboBox_Cliente->addItem(cl.value(0).toString());
                      } while (cl.next());
                   }
                  

                  and check if it still crashes?

                  1 Reply Last reply
                  0
                  • TheCipo76T TheCipo76

                    Hi,
                    i've populated from database n.1 comboBox and all is OK

                    if i click on Annulla pushbutton (this is the code):

                    void inserisciarticolo::on_pushButton_Annulla_clicked()
                    {
                        // ANNULLA
                        if (aDatabase.open()) {
                            aDatabase.close();
                        }
                        close();
                    }
                    

                    and try to re-load the dialog (from application menu)

                    after first record of database additem() crashes the application

                    if i comment the additem() all works

                    this is the code i've used to load the comboBox data:

                    QSqlQuery cl;
                        cl.prepare("Select RAGSOC from CLIENTI order by RAGSOC ASC");
                        ui->comboBox_Cliente->clear();
                        if (cl.exec()) {
                            cl.first();
                            do {
                                ui->comboBox_Cliente->addItem(cl.value(0).toString());
                            } while (cl.next());
                        }
                    

                    ideas??

                    Thanks in advance.

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

                    @TheCipo76

                    after first record of database additem() crashes the application

                    Has nobody yet asked you to run this in a debugger (e.g. from Qt Creator)? And give us the stacktrace? EDIT: Oh, @VRonin has 2 posts above. Please do so!

                    1 Reply Last reply
                    1
                    • VRoninV VRonin

                      This is turning into a mistery now. Can you post the stack trace at the moment of crash?

                      TheCipo76T Offline
                      TheCipo76T Offline
                      TheCipo76
                      wrote on last edited by
                      #21

                      @VRonin you mean the os x crash report??

                      VRoninV JonBJ 2 Replies Last reply
                      0
                      • TheCipo76T TheCipo76

                        @VRonin you mean the os x crash report??

                        VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by
                        #22

                        @TheCipo76 said in comboBox->additem() crash application..:

                        you mean the os x crash report??

                        Nope, the stack trace which is a log of all the functions called up to the point of crash. If you use Qt Creator, see http://doc.qt.io/qtcreator/creator-debug-mode.html#viewing-call-stack-trace

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        1 Reply Last reply
                        2
                        • TheCipo76T TheCipo76

                          @VRonin you mean the os x crash report??

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

                          @TheCipo76
                          Do you sit inside Qt Creator and run your app from within there via the debugger? We are expecting that when something "crashes", the debugger will catch that and show a stacktrace of exactly where it was in your code.

                          1 Reply Last reply
                          2
                          • TheCipo76T Offline
                            TheCipo76T Offline
                            TheCipo76
                            wrote on last edited by
                            #24

                            1 QLineEdit::setText(QString const&) 0x1003727e8
                            2 inserisciarticolo::on_comboBox_Cliente_currentTextChanged(QString const&) inserisciarticolo.cpp 497 0x10003ce05
                            3 inserisciarticolo::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) moc_inserisciarticolo.cpp 92 0x10008ec0d
                            4 inserisciarticolo::qt_metacall(QMetaObject::Call, int, void * *) moc_inserisciarticolo.cpp 124 0x10008eda5
                            5 QMetaObject::activate(QObject *, int, int, void * *) 0x100edf7d6
                            6 QComboBoxPrivate::_q_emitCurrentIndexChanged(QModelIndex const&) 0x100332724
                            7 QComboBoxPrivate::setCurrentIndex(QModelIndex const&) 0x100337121
                            8 QComboBoxPrivate::_q_rowsInserted(QModelIndex const&, int, int) 0x100336048
                            9 QMetaObject::activate(QObject *, int, int, void * *) 0x100edfaaa
                            10 QAbstractItemModel::endInsertRows() 0x100e697f2
                            11 QStandardItemPrivate::insertRows(int, int, QList<QStandardItem *> const&) 0x100b043ca
                            12 QComboBox::insertItem(int, QIcon const&, QString const&, QVariant const&) 0x1003389fc
                            13 QComboBox::insertItem(int, QString const&, QVariant const&) qcombobox.h 279 0x10002106d
                            14 QComboBox::addItem(QString const&, QVariant const&) qcombobox.h 272 0x100017aa7
                            15 inserisciarticolo::inserisciarticolo(QWidget *, QString const&, QString const&) inserisciarticolo.cpp 70 0x1000337d8
                            16 inserisciarticolo::inserisciarticolo(QWidget *, QString const&, QString const&) inserisciarticolo.cpp 19 0x100038c4d
                            17 MainWindow::on_action_InsArticolo_triggered() mainwindow.cpp 100 0x100008ae8
                            18 MainWindow::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) moc_mainwindow.cpp 162 0x10008d839
                            19 MainWindow::qt_metacall(QMetaObject::Call, int, void * *) moc_mainwindow.cpp 214 0x10008db45
                            20 QMetaObject::activate(QObject *, int, int, void * *) 0x100edf7d6
                            21 QAction::activate(QAction::ActionEvent) 0x10022d615
                            22 QMenuPrivate::activateCausedStack(QVector<QPointer<QWidget>> const&, QAction *, QAction::ActionEvent, bool) 0x1003b010f
                            23 QMenuPrivate::activateAction(QAction *, QAction::ActionEvent, bool) 0x1003ad6c4
                            24 QWidget::event(QEvent *) 0x100271050
                            25 QMenu::event(QEvent *) 0x1003b53c2
                            26 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x100236d32
                            27 QApplication::notify(QObject *, QEvent *) 0x100239b8d
                            28 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x100eae85f
                            29 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool) 0x100237660
                            30 QWidgetWindow::handleMouseEvent(QMouseEvent *) 0x1002913a1
                            31 QWidgetWindow::event(QEvent *) 0x10028fe60
                            32 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x100236d32
                            33 QApplication::notify(QObject *, QEvent *) 0x10023810d
                            34 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x100eae85f
                            35 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *) 0x1007ec094
                            36 QWindowSystemInterface::sendWindowSystemEvents(QFlagsQEventLoop::ProcessEventsFlag) 0x1007d3d4b
                            37 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *) 0x105a0faf1
                            38 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 0x7fff3be90155
                            39 __CFRunLoopDoSource0 0x7fff3be900fb
                            40 __CFRunLoopDoSources0 0x7fff3be73b95
                            41 __CFRunLoopRun 0x7fff3be7313e
                            42 CFRunLoopRunSpecific 0x7fff3be72a28
                            43 RunCurrentEventLoopInMode 0x7fff3b10bb35
                            44 ReceiveNextEventCommon 0x7fff3b10b774
                            45 _BlockUntilNextEventMatchingListInModeWithFilter 0x7fff3b10b5e8
                            46 _DPSNextEvent 0x7fff393c7eb7
                            47 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x7fff393c6c56
                            48 -[NSApplication run] 0x7fff393c0cb9
                            49 QCocoaEventDispatcher::processEvents(QFlagsQEventLoop::ProcessEventsFlag) 0x105a0e8ed
                            50 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) 0x100eaa3b2
                            51 QCoreApplication::exec() 0x100eaef72
                            52 main main.cpp 11 0x100003b54
                            53 start 0x7fff6905508d

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

                              The macOS crash report should also contain useful information in that regard so you can post it.

                              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
                              0
                              • TheCipo76T TheCipo76

                                1 QLineEdit::setText(QString const&) 0x1003727e8
                                2 inserisciarticolo::on_comboBox_Cliente_currentTextChanged(QString const&) inserisciarticolo.cpp 497 0x10003ce05
                                3 inserisciarticolo::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) moc_inserisciarticolo.cpp 92 0x10008ec0d
                                4 inserisciarticolo::qt_metacall(QMetaObject::Call, int, void * *) moc_inserisciarticolo.cpp 124 0x10008eda5
                                5 QMetaObject::activate(QObject *, int, int, void * *) 0x100edf7d6
                                6 QComboBoxPrivate::_q_emitCurrentIndexChanged(QModelIndex const&) 0x100332724
                                7 QComboBoxPrivate::setCurrentIndex(QModelIndex const&) 0x100337121
                                8 QComboBoxPrivate::_q_rowsInserted(QModelIndex const&, int, int) 0x100336048
                                9 QMetaObject::activate(QObject *, int, int, void * *) 0x100edfaaa
                                10 QAbstractItemModel::endInsertRows() 0x100e697f2
                                11 QStandardItemPrivate::insertRows(int, int, QList<QStandardItem *> const&) 0x100b043ca
                                12 QComboBox::insertItem(int, QIcon const&, QString const&, QVariant const&) 0x1003389fc
                                13 QComboBox::insertItem(int, QString const&, QVariant const&) qcombobox.h 279 0x10002106d
                                14 QComboBox::addItem(QString const&, QVariant const&) qcombobox.h 272 0x100017aa7
                                15 inserisciarticolo::inserisciarticolo(QWidget *, QString const&, QString const&) inserisciarticolo.cpp 70 0x1000337d8
                                16 inserisciarticolo::inserisciarticolo(QWidget *, QString const&, QString const&) inserisciarticolo.cpp 19 0x100038c4d
                                17 MainWindow::on_action_InsArticolo_triggered() mainwindow.cpp 100 0x100008ae8
                                18 MainWindow::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *) moc_mainwindow.cpp 162 0x10008d839
                                19 MainWindow::qt_metacall(QMetaObject::Call, int, void * *) moc_mainwindow.cpp 214 0x10008db45
                                20 QMetaObject::activate(QObject *, int, int, void * *) 0x100edf7d6
                                21 QAction::activate(QAction::ActionEvent) 0x10022d615
                                22 QMenuPrivate::activateCausedStack(QVector<QPointer<QWidget>> const&, QAction *, QAction::ActionEvent, bool) 0x1003b010f
                                23 QMenuPrivate::activateAction(QAction *, QAction::ActionEvent, bool) 0x1003ad6c4
                                24 QWidget::event(QEvent *) 0x100271050
                                25 QMenu::event(QEvent *) 0x1003b53c2
                                26 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x100236d32
                                27 QApplication::notify(QObject *, QEvent *) 0x100239b8d
                                28 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x100eae85f
                                29 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool) 0x100237660
                                30 QWidgetWindow::handleMouseEvent(QMouseEvent *) 0x1002913a1
                                31 QWidgetWindow::event(QEvent *) 0x10028fe60
                                32 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x100236d32
                                33 QApplication::notify(QObject *, QEvent *) 0x10023810d
                                34 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x100eae85f
                                35 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *) 0x1007ec094
                                36 QWindowSystemInterface::sendWindowSystemEvents(QFlagsQEventLoop::ProcessEventsFlag) 0x1007d3d4b
                                37 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *) 0x105a0faf1
                                38 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 0x7fff3be90155
                                39 __CFRunLoopDoSource0 0x7fff3be900fb
                                40 __CFRunLoopDoSources0 0x7fff3be73b95
                                41 __CFRunLoopRun 0x7fff3be7313e
                                42 CFRunLoopRunSpecific 0x7fff3be72a28
                                43 RunCurrentEventLoopInMode 0x7fff3b10bb35
                                44 ReceiveNextEventCommon 0x7fff3b10b774
                                45 _BlockUntilNextEventMatchingListInModeWithFilter 0x7fff3b10b5e8
                                46 _DPSNextEvent 0x7fff393c7eb7
                                47 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] 0x7fff393c6c56
                                48 -[NSApplication run] 0x7fff393c0cb9
                                49 QCocoaEventDispatcher::processEvents(QFlagsQEventLoop::ProcessEventsFlag) 0x105a0e8ed
                                50 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) 0x100eaa3b2
                                51 QCoreApplication::exec() 0x100eaef72
                                52 main main.cpp 11 0x100003b54
                                53 start 0x7fff6905508d

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

                                @TheCipo76

                                2 inserisciarticolo::on_comboBox_Cliente_currentTextChanged(QString const&) inserisciarticolo.cpp 497 0x10003ce05

                                While executing your comboBox->additem(), you have a slot on_comboBox_Cliente_currentTextChanged, which does a setText(), which you haven't told us about? What is your code for that function...? Because I think you're going to find the crash is there :)

                                P.S.
                                This is why learning to use a debugger will be about the most productive time investment you can make!

                                TheCipo76T 1 Reply Last reply
                                3
                                • JonBJ JonB

                                  @TheCipo76

                                  2 inserisciarticolo::on_comboBox_Cliente_currentTextChanged(QString const&) inserisciarticolo.cpp 497 0x10003ce05

                                  While executing your comboBox->additem(), you have a slot on_comboBox_Cliente_currentTextChanged, which does a setText(), which you haven't told us about? What is your code for that function...? Because I think you're going to find the crash is there :)

                                  P.S.
                                  This is why learning to use a debugger will be about the most productive time investment you can make!

                                  TheCipo76T Offline
                                  TheCipo76T Offline
                                  TheCipo76
                                  wrote on last edited by
                                  #27

                                  @JonB because i think the problem is not there.. arg1 was not used..
                                  it's a blanking form slot..

                                  void inserisciarticolo::on_comboBox_Cliente_currentTextChanged(const QString &arg1)
                                  {
                                      if (AzzeraI == true) {
                                          for (int i=0;i<10;i++) {
                                              array_Codice[i]->setText("");
                                              array_Descrizione[i]->setText("");
                                              array_Qta[i]->setValue(0);
                                              array_Origine[i]->setCurrentText("");
                                              array_Fornitore[i]->setCurrentText("");
                                          }
                                      }
                                  }
                                  

                                  You're right!! The problem was "AzzeraI" var..
                                  i set it to false on dialog loading and all works!

                                  Thanks to all

                                  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