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. QLineEdit + QUndoCommand::mergeWidth crashes App
Forum Updated to NodeBB v4.3 + New Features

QLineEdit + QUndoCommand::mergeWidth crashes App

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 1.6k 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by ModelTech
    #1

    I am creating an application that uses the undo framework. I also use a model-view architecture for my data structure and the pimpl pattern to have a clear api to my model classes. I run however into a problem with combining QLineEdit as widget to induce changes to my model via QUndoCommands. A simplified application that has the considered problem can be downloaded here.

    You can recreate the problem by entering numbers into one of the two QLineEdit boxes and do so until the notation changes to scientific syntax. Subsequently hit the undo button on the left to induce the crash. When removing the overridden QUndoCommand::mergeWith methods for my commands, the crash is gone but the behavior for the above scenario is weird. Does anybody have an idea on how to fix this?

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

      Hi,

      You should add:

      • Which version of Qt you are using
      • Which version you are running on
      • A stack trace of the crash you get

      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
      • ModelTechM Offline
        ModelTechM Offline
        ModelTech
        wrote on last edited by
        #3

        Good question! The crash appeared on Qt5.7.1 in Ubuntu 16.04. So, I upgraded to Qt5.12.0.

        What is rather annoying is that it is not completely clear under which circumstances the crash occurs. After trying several times, I got it to occur as follows: add numbers to the QLineEdit below 'Time' until the value automatically changes to scientific notation. Subsequently, undo and then perform a redo. But it seems better to play with it and perhaps restart the app so now and then to get to a crash. I am not sure how to save a stack trace, but below is something that I could copy from the debugger. In some cases, I got the following messages as application output:

        07:31:04: Debugging starts
          OpenType support missing for "Ubuntu", script 11
          OpenType support missing for "Ubuntu", script 9
          OpenType support missing for "Ubuntu", script 13
          OpenType support missing for "Ubuntu", script 17
        07:37:26: Debugging has finished
        
        07:37:30: Starting undo_issue/build/debug/undo_issue...
        07:37:37: The program has unexpectedly finished.
        07:37:37: The process was ended forcefully.
        07:37:37: build/debug/undo_issue crashed.
        
        1  QUndoCommand::actionText() const                                                                                                             0x7ffff7a34d20 
        2  QUndoStack::undoText() const                                                                                                                 0x7ffff7a35241 
        3  QUndoStackPrivate::setIndex(int, bool)                                                                                                       0x7ffff7a3530d 
        4  QUndoStack::redo()                                                                                                                           0x7ffff7a366fb 
        5  QMetaObject::activate(QObject *, int, int, void * *)                                                                                         0x7ffff6873629 
        6  QAction::triggered(bool)                                                                                                                     0x7ffff76e5882 
        7  QAction::activate(QAction::ActionEvent)                                                                                                      0x7ffff76e7ca0 
        8  QAbstractButtonPrivate::click()                                                                                                              0x7ffff77d3450 
        9  QAbstractButton::mouseReleaseEvent(QMouseEvent *)                                                                                            0x7ffff77d3565 
        10 QToolButton::mouseReleaseEvent(QMouseEvent *)                                                                                                0x7ffff78b192a 
        11 QWidget::event(QEvent *)                                                                                                                     0x7ffff7729348 
        12 QToolButton::event(QEvent *)                                                                                                                 0x7ffff78b19f9 
        13 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                      0x7ffff76eb85c 
        14 QApplication::notify(QObject *, QEvent *)                                                                                                    0x7ffff76f2fcf 
        15 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                       0x7ffff6847c18 
        16 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool, bool)             0x7ffff76f1f0a 
        17 QWidgetWindow::handleMouseEvent(QMouseEvent *)                                                                                               0x7ffff7742d4b 
        18 QWidgetWindow::event(QEvent *)                                                                                                               0x7ffff774586b 
        19 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                      0x7ffff76eb85c 
        20 QApplication::notify(QObject *, QEvent *)                                                                                                    0x7ffff76f29f0 
        21 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                       0x7ffff6847c18 
        22 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *)                                                       0x7ffff6eb01e7 
        23 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *)                                         0x7ffff6eb1795 
        24 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                        0x7ffff6e8d44b 
        25 xcbSourceDispatch(_GSource *, int ( *)(void *), void *)                                                                                      0x7fffef89c67a 
        26 g_main_context_dispatch                                                                                                                      0x7ffff29c3197 
        27 ??                                                                                                                                           0x7ffff29c33f0 
        28 g_main_context_iteration                                                                                                                     0x7ffff29c349c 
        29 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                                   0x7ffff689edcf 
        30 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)                                                                                      0x7ffff684657a 
        31 QCoreApplication::exec()                                                                                                                     0x7ffff684ef80 
        32 main                                                                                                                             main.cpp 10 0x4046c2       
        
        1 Reply Last reply
        0
        • ModelTechM Offline
          ModelTechM Offline
          ModelTech
          wrote on last edited by ModelTech
          #4

          Well, was able to get a glimpse of some strange behavior and after hitting 'Undo' a crash. The screenshot before hitting 'Undo' and the applocation output (this was unfortunately not done in the debugger). I am slowly starting to think that the call to QObject::tr in my QUndoCommand constructors are causing the problem...

          The example app can be downloaded from https://modeltech.org/temp/undo_issue.zip

          Strange Text

          Application Output:

          09:30:52: Starting undo_issue/build/debug/undo_issue...
            OpenType support missing for "Ubuntu", script 18
            OpenType support missing for "Ubuntu", script 10
            OpenType support missing for "Ubuntu", script 17
            OpenType support missing for "Ubuntu", script 15
          09:32:31: The program has unexpectedly finished.
          09:32:31: The process was ended forcefully.
          09:32:31: undo_issue/build/debug/undo_issue crashed.
          
          1 Reply Last reply
          0
          • ModelTechM Offline
            ModelTechM Offline
            ModelTech
            wrote on last edited by
            #5

            After removing the QObject::tr calls, it still crashes, but now the stack trace looks a bit different. I am not aware of a method isObsolete for QUndoCommand but it seems that there is a problem with that :?

            1  QUndoCommand::isObsolete() const                                                                                                             0x7ffff7a34ce4 
            2  QUndoStack::undo()                                                                                                                           0x7ffff7a361db 
            3  QMetaObject::activate(QObject *, int, int, void * *)                                                                                         0x7ffff6873629 
            4  QAction::triggered(bool)                                                                                                                     0x7ffff76e5882 
            5  QAction::activate(QAction::ActionEvent)                                                                                                      0x7ffff76e7ca0 
            6  QAbstractButtonPrivate::click()                                                                                                              0x7ffff77d3450 
            7  QAbstractButton::mouseReleaseEvent(QMouseEvent *)                                                                                            0x7ffff77d3565 
            8  QToolButton::mouseReleaseEvent(QMouseEvent *)                                                                                                0x7ffff78b192a 
            9  QWidget::event(QEvent *)                                                                                                                     0x7ffff7729348 
            10 QToolButton::event(QEvent *)                                                                                                                 0x7ffff78b19f9 
            11 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                      0x7ffff76eb85c 
            12 QApplication::notify(QObject *, QEvent *)                                                                                                    0x7ffff76f2fcf 
            13 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                       0x7ffff6847c18 
            14 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool, bool)             0x7ffff76f1f0a 
            15 QWidgetWindow::handleMouseEvent(QMouseEvent *)                                                                                               0x7ffff7742d4b 
            16 QWidgetWindow::event(QEvent *)                                                                                                               0x7ffff774586b 
            17 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                      0x7ffff76eb85c 
            18 QApplication::notify(QObject *, QEvent *)                                                                                                    0x7ffff76f29f0 
            19 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                       0x7ffff6847c18 
            20 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *)                                                       0x7ffff6eb01e7 
            21 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *)                                         0x7ffff6eb1795 
            22 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                        0x7ffff6e8d44b 
            23 xcbSourceDispatch(_GSource *, int ( *)(void *), void *)                                                                                      0x7fffef89c67a 
            24 g_main_context_dispatch                                                                                                                      0x7ffff29c3197 
            25 ??                                                                                                                                           0x7ffff29c33f0 
            26 g_main_context_iteration                                                                                                                     0x7ffff29c349c 
            27 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                                   0x7ffff689edeb 
            28 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)                                                                                      0x7ffff684657a 
            29 QCoreApplication::exec()                                                                                                                     0x7ffff684ef80 
            30 main                                                                                                                             main.cpp 10 0x4046b2       
            
            
            1 Reply Last reply
            0
            • ModelTechM Offline
              ModelTechM Offline
              ModelTech
              wrote on last edited by
              #6

              After completely removing the setText calls in the QUndoCommand, I still have a crash, now with yet another stack trace

              1  __memmove_ssse3_back                                                                                                             memcpy-ssse3-back.S 1544 0x7ffff5dd7e2f 
              2  QListData::remove(int)                                                                                                                                    0x7ffff66dbcc4 
              3  QUndoStack::undo()                                                                                                                                        0x7ffff7a36244 
              4  QMetaObject::activate(QObject *, int, int, void * *)                                                                                                      0x7ffff6873629 
              5  QAction::triggered(bool)                                                                                                                                  0x7ffff76e5882 
              6  QAction::activate(QAction::ActionEvent)                                                                                                                   0x7ffff76e7ca0 
              7  QAbstractButtonPrivate::click()                                                                                                                           0x7ffff77d3450 
              8  QAbstractButton::mouseReleaseEvent(QMouseEvent *)                                                                                                         0x7ffff77d3565 
              9  QToolButton::mouseReleaseEvent(QMouseEvent *)                                                                                                             0x7ffff78b192a 
              10 QWidget::event(QEvent *)                                                                                                                                  0x7ffff7729348 
              11 QToolButton::event(QEvent *)                                                                                                                              0x7ffff78b19f9 
              12 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                                   0x7ffff76eb85c 
              13 QApplication::notify(QObject *, QEvent *)                                                                                                                 0x7ffff76f2fcf 
              14 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                                    0x7ffff6847c18 
              15 QApplicationPrivate::sendMouseEvent(QWidget *, QMouseEvent *, QWidget *, QWidget *, QWidget * *, QPointer<QWidget>&, bool, bool)                          0x7ffff76f1f0a 
              16 QWidgetWindow::handleMouseEvent(QMouseEvent *)                                                                                                            0x7ffff7742d4b 
              17 QWidgetWindow::event(QEvent *)                                                                                                                            0x7ffff774586b 
              18 QApplicationPrivate::notify_helper(QObject *, QEvent *)                                                                                                   0x7ffff76eb85c 
              19 QApplication::notify(QObject *, QEvent *)                                                                                                                 0x7ffff76f29f0 
              20 QCoreApplication::notifyInternal2(QObject *, QEvent *)                                                                                                    0x7ffff6847c18 
              21 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *)                                                                    0x7ffff6eb01e7 
              22 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *)                                                      0x7ffff6eb1795 
              23 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                                     0x7ffff6e8d44b 
              24 xcbSourceDispatch(_GSource *, int ( *)(void *), void *)                                                                                                   0x7fffef89c67a 
              25 g_main_context_dispatch                                                                                                                                   0x7ffff29c3197 
              26 ??                                                                                                                                                        0x7ffff29c33f0 
              27 g_main_context_iteration                                                                                                                                  0x7ffff29c349c 
              28 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)                                                                                0x7ffff689edcf 
              29 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)                                                                                                   0x7ffff684657a 
              30 QCoreApplication::exec()                                                                                                                                  0x7ffff684ef80 
              31 main                                                                                                                             main.cpp            10   0x404642       
              
              
              1 Reply Last reply
              0
              • ModelTechM Offline
                ModelTechM Offline
                ModelTech
                wrote on last edited by
                #7

                Still looking for ideas / suggestions ...

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You should try to create a minimal, compilable example so we can try to reproduce it. Or even better you'll find your problem while trying to create the example.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  ModelTechM 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    You should try to create a minimal, compilable example so we can try to reproduce it. Or even better you'll find your problem while trying to create the example.

                    ModelTechM Offline
                    ModelTechM Offline
                    ModelTech
                    wrote on last edited by ModelTech
                    #9

                    @Christian-Ehrlicher I actually did create one, but apparently I forgot to post the link... So, here it is https://modeltech.org/temp/undo_issue.zip

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Your testapp works fine here with Qt5.11.2 on Linux. Is there something special I've to do?

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • ModelTechM Offline
                        ModelTechM Offline
                        ModelTech
                        wrote on last edited by
                        #11

                        Hmm, that is interesting. What Linux are you using? Perhaps I should downgrade back to Qt5.11.2 to see whether that would solve the issue...

                        1 Reply Last reply
                        0
                        • Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          It's also working with 5.12 / 64 bit.

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          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