Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Application Crash
Forum Updated to NodeBB v4.3 + New Features

Qt Application Crash

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
12 Posts 3 Posters 4.8k Views 1 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.
  • M Mr .Wu

    I have make a application in Qt . It running on Qt 5.8 platform . I use a mousearea control . I found that When I double click quickly . The Application will be crash .

    the crash log :

    Program received signal SIGSEGV, Segmentation fault.
    0xb6da7b0c in QQuickEventPoint::grabber() const ()
    from /data/qt/lib/libQt5Quick.so.5
    (gdb) bt
    bt
    #0 0xb6da7b0c in QQuickEventPoint::grabber() const ()
    from /data/qt/lib/libQt5Quick.so.5
    #1 0xb6e3d100 in QQuickMouseArea::mouseReleaseEvent(QMouseEvent*) ()
    from /data/qt/lib/libQt5Quick.so.5
    #2 0xb6dc2678 in QQuickItem::event(QEvent*) ()
    from /data/qt/lib/libQt5Quick.so.5
    #3 0xb60c3278 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #4 0xb60c3408 in QCoreApplication::notify(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #5 0xb60c3338 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #6 0xb6dd411c in QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem*, QQuickPo
    interEvent*) () from /data/qt/lib/libQt5Quick.so.5
    #7 0xb6dd4c54 in QQuickWindowPrivate:: (QQuickItem*,
    QQuickPointerEvent*, QSet<QQuickItem*>) () from /data/qt/lib/libQt5Quick.so.5
    #8 0xb6dd4ec8 in QQuickWindowPrivate::deliverUpdatedTouchPoints(QQuickPointerTo
    uchEvent
    , QSet<QQuickItem*>) () from /data/qt/lib/libQt5Quick.so.5
    #9 0xb6dd5af8 in QQuickWindowPrivate::deliverTouchEvent(QQuickPointerTouchEvent
    ) () from /data/qt/lib/libQt5Quick.so.5
    #10 0xb6dd5bdc in QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent
    )
    () from /data/qt/lib/libQt5Quick.so.5
    #11 0xb6dd65b8 in QQuickWindowPrivate::handleTouchEvent(QTouchEvent
    ) ()
    ---Type <return> to continue, or q <return> to quit---

    from /data/qt/lib/libQt5Quick.so.5
    #12 0xb6dd7e3c in QQuickWindow::event(QEvent*) ()
    from /data/qt/lib/libQt5Quick.so.5
    #13 0xb60c3278 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #14 0xb60c3408 in QCoreApplication::notify(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #15 0xb60c3338 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    from /data/qt/lib/libQt5Core.so.5
    #16 0xb68ec1a8 in QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfa
    cePrivate::TouchEvent*) () from /data/qt/lib/libQt5Gui.so.5
    #17 0xb68eef38 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystem
    InterfacePrivate::WindowSystemEvent*) () from /data/qt/lib/libQt5Gui.so.5
    #18 0xb68c89f8 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLo
    op::ProcessEventsFlag>) () from /data/qt/lib/libQt5Gui.so.5
    #19 0xb5cb8600 in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::Proc
    essEventsFlag>) () from /data/qt/plugins/platforms/libqlinuxfb.so
    #20 0xb60c0f18 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag

    ) () from /data/qt/lib/libQt5Core.so.5
    #21 0xb60c1328 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) ()
    from /data/qt/lib/libQt5Core.so.5
    #22 0xb60c9980 in QCoreApplication::exec() () from /data/qt/lib/libQt5Core.so.5
    #23 0x00016a84 in main (argc=0, argv=<optimized out>) at main.cpp:155
    (gdb)

    (gdb)

    (gdb) bt

    A Offline
    A Offline
    ambershark
    wrote on last edited by
    #2

    @Mr-.Wu Can you share the QML code (or better yet a minimal example) that can duplicate the crash?

    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

    M 2 Replies Last reply
    0
    • M Offline
      M Offline
      Mr .Wu
      wrote on last edited by
      #3

      Chat.qml

      import QtQuick 2.4
      import "qrc:/ui/javascript/watch_constants.js" as Constants
      import "qrc:/ui/javascript/watch_functions.js" as Functions
      
      ChatForm {
          id: chatForm
      
          Connections {
              target: btnChat
              onClicked: {
                  Functions.getWindow("ChatWindow.qml").createChatListComponent()
              }
          }
      }
      
      

      ChatForm.ui.qml

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.0
      import "qrc:/ui/javascript/watch_constants.js" as Constants
      
      Item {
          width: 240
          height: 240
      
          property alias txtChat: txtChat
          property alias btnChat: btnChat
      
          Rectangle {
              id: rectangleChatsArea
              anchors.fill : parent
              color: Constants.LauncherBgColor
      
              Image {
                  id: imageChatBg
                  source: "qrc:/ui/images/launcher_bg.png"
                  width: parent.width
                  height: parent.height
              }
      
              Rectangle {
                  height: 115
                  width: 115
                  anchors.verticalCenter: parent.verticalCenter
                  anchors.horizontalCenter: parent.horizontalCenter
                  color: Constants.LauncherColor_Transparent
      
                  Image {
                      id: imageChatIoc
                      source: "qrc:/ui/images/chat_ioc.png"
                  }
                  MouseArea {
                      id: btnChat
                      anchors.fill: parent
                  }
              }
              Text {
                  id: txtChat
                  font.pixelSize: Constants.LauncherFontPixelSize
                  font.family: Constants.LauncherFontFamily
                  horizontalAlignment: Text.AlignHCenter
                  anchors.bottom: parent.bottom
                  anchors.bottomMargin: 24
                  anchors.horizontalCenter: parent.horizontalCenter
                  color: Constants.LauncherTextColor
                  width: 72
                  height: 24
              }
          }
      }
      

      RootWindow.qml

      import QtQuick 2.7
      import QtQuick.Window 2.2
      import "qrc:/ui/javascript/watch_constants.js" as Constants
      import "qrc:/ui/javascript/watch_functions.js" as Functions
      
      Window {
          id: rootWindow
          x: 0
          y: 0
          width: 240
          height: 240
          flags: Qt.FramelessWindowHint
      
          // 显示区域
          property alias rootRectangle: rootRectangle
          // 窗体组件(当前显示的组件)
          property var component: null
          // 点击事件
          property alias rootMouseArea: rootMouseArea
      
      
          Rectangle {
              x: 0
              y: 0
              id: rootRectangle
              width: parent.width
              height: parent.height
              color: Constants.LauncherBgColor
      
              MouseArea {
                  x: 0
                  y: 0
                  id: rootMouseArea
                  anchors.fill: parent
              }
          }
      
          /************************************************** Function *******************************************************/
      
          // 创建组件
          function setupComponent(qml_file) {
              return setupComponentVisible(qml_file, true)
          }
      
      
          // 创建组件
          function setupComponentVisible(qml_file, visible) {
              var parent = null
              if (component == null)
                  parent = rootRectangle
              else
                  parent = component
              var ret = Functions.dynamicCreateComponent(parent, qml_file, visible)
              if (ret != null)
                  component = ret
              if(visible)
                  component.visible = true
              return component
          }
      }
      
      

      watch_functions.js

      /*
       * Func: create component
       * Desc: dynamic create component
       * Para: parent , qml file , visible - true or false
       * Ret : component
       */
      function dynamicCreateComponent(parent,qml_file,visible)
      {
          if(parent == null)
          {
              console.log("create component failed . the parent is null .");
              return null;
          }
          if(qml_file == null)
          {
              console.log("create component failed . the qml file is null .");
              return null;
          }
      
          var component = Qt.createComponent(qml_file);
          var qml_object = component.createObject(parent,{"x": 0, "y": 0});
          if(qml_object !=null)
              qml_object.visible = visible;
      
          console.log("create component : " + qml_object + " , parent : " + qml_object.parent);
          return qml_object;
      }
      
      /*
       * Func: get window
       * Desc: get window
       * Para: window name
       * Ret :
       */
      function getWindow(window_name)
      {
          if(window_name == null)
          {
              console.log("the window name is null . can't get it .");
              return null;
          }
          var window = ui_management.existsWindow(window_name);
          if(window == null)
          {
              console.log("can't find the window named : " + window_name);
              return null;
          }
          return window.getQmlObject();
      }
      
      

      ChatWindow.qml

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.0
      import "qrc:/ui"
      import "qrc:/ui/javascript/watch_constants.js" as Constants
      import "qrc:/ui/javascript/watch_functions.js" as Functions
      
      RootWindow {
          id: chatWindow
          visible: false
          width: 240
          height: 240
      
          signal
          createChatListComponent;
      
          Component.onCompleted: {
              createChatListComponent.connect(setupListView)
              console.log("Chat Window Completed")
          }
      
          Component.onDestruction: {
              createChatListComponent.disconnect(setupListView)
              console.log("Chat Window Destruction")
          }
      
          /************************************************** Function *******************************************************/
      
          // 打开消息列表
          function setupListView() {
              setupComponent(Constants.Compontent_ChatList)
          }
      }
      
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr .Wu
        wrote on last edited by
        #4

        When I double click quickly the mousearea named btnChat . The Application will be crash . This is a probabilistic event

        1 Reply Last reply
        0
        • A ambershark

          @Mr-.Wu Can you share the QML code (or better yet a minimal example) that can duplicate the crash?

          M Offline
          M Offline
          Mr .Wu
          wrote on last edited by
          #5

          @ambershark can you found the problem ?

          A 1 Reply Last reply
          0
          • M Mr .Wu

            @ambershark can you found the problem ?

            A Offline
            A Offline
            ambershark
            wrote on last edited by ambershark
            #6

            @Mr-.Wu I'll play with it tomorrow and see if it crashes for me. I'll let you know.

            Edit: Sorry didn't have time today, but will try to check it this week for sure. Busy time deadline wise for me right now.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            M 1 Reply Last reply
            1
            • A ambershark

              @Mr-.Wu I'll play with it tomorrow and see if it crashes for me. I'll let you know.

              Edit: Sorry didn't have time today, but will try to check it this week for sure. Busy time deadline wise for me right now.

              M Offline
              M Offline
              Mr .Wu
              wrote on last edited by
              #7

              @ambershark said in Qt Application Crash:

              Sorry didn't have time today, but will try to check it this week for sure. Busy time deadline wise for me right now.

              Okay. Thanks

              1 Reply Last reply
              0
              • A ambershark

                @Mr-.Wu Can you share the QML code (or better yet a minimal example) that can duplicate the crash?

                M Offline
                M Offline
                Mr .Wu
                wrote on last edited by
                #8

                @ambershark Did you do the test?

                A 1 Reply Last reply
                0
                • M Mr .Wu

                  @ambershark Did you do the test?

                  A Offline
                  A Offline
                  ambershark
                  wrote on last edited by
                  #9

                  @Mr-.Wu Sorry I haven't yet. I have a tight deadline and had to write a ton of code this week. Worked some 12 hour days. I will try to test it soon though. Hopefully someone else can give it a shot too so you're not waiting on just me.

                  My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                  M 1 Reply Last reply
                  0
                  • A ambershark

                    @Mr-.Wu Sorry I haven't yet. I have a tight deadline and had to write a ton of code this week. Worked some 12 hour days. I will try to test it soon though. Hopefully someone else can give it a shot too so you're not waiting on just me.

                    M Offline
                    M Offline
                    Mr .Wu
                    wrote on last edited by
                    #10

                    @ambershark Can you help us . We can't found the problem how to cause.

                    S A 2 Replies Last reply
                    0
                    • M Mr .Wu

                      @ambershark Can you help us . We can't found the problem how to cause.

                      S Offline
                      S Offline
                      Schluchti
                      wrote on last edited by
                      #11

                      @Mr-.Wu Have you tried running the code with Qt 5.9? 5.9 is a long term release and if it's really a bug chances are good that it will be fixed with one of the bugfix releases.

                      Want to read more about Qt?

                      https://gympulsr.com/blog/qt/

                      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                      1 Reply Last reply
                      0
                      • M Mr .Wu

                        @ambershark Can you help us . We can't found the problem how to cause.

                        A Offline
                        A Offline
                        ambershark
                        wrote on last edited by
                        #12

                        @Mr-.Wu Ok finally had some time today to look at it. With the code you provided I can't get it to run as it's missing things.

                        So here's what we can do. Can you provide a simple example that duplicates the behavior? Does this happen with any mousearea or is it specific to one in your project? If you setup just a simple rect with a mousearea could you get it to crash? Does it crash while running in qmlscene or only when you run as an app?:

                        I tested with the following code:

                        import QtQuick 2.4
                        import QtQuick.Controls 2.0
                        
                        Rectangle {
                                width: 400
                                height: 400
                                color: "black"
                        
                                MouseArea {
                                        anchors.fill: parent
                                        onClicked: { parent.color = "red" }
                                        onDoubleClicked: { parent.color = "black" }
                                }
                        }
                        

                        Everything was fine as fast as I could click. I just ran it with qmlscene though. Try that on your system and see if you can duplicate the crash if not, see what is different between how you use a MouseArea and what this simple one is doing. Then try to step it from a base MouseArea to your and find the point at which it breaks.

                        If you could give me a working project I could test yours and see if I can find the issue. I'm still learning QML myself though. I've been using Qt with QtWidgets for a very long time but am pretty new to QML as of last year. And since I haven't had a big project that needed it I just haven't had the exposure to the small problems it can produce yet. So I don't see anything obvious in your code.

                        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved