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. QSharedPointer and QML

QSharedPointer and QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 2.8k 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.
  • E Offline
    E Offline
    Eligijus
    wrote on last edited by Eligijus
    #1

    Hello,

    I'm porting QWidget library to QQuickItem. Important to note that there are uses of QSharedPointer in library.
    I register class to access in qml qmlRegisterType() .
    Now my problem that I need to create and delete class object quite often and sometimes application crashes of segmentation fault. After following stack trace it leads to class destructor and QSharedPointer.

    So is QSharedPointer compatible with QML? And what are the solutions to incompatibility?

    E 1 Reply Last reply
    0
    • E Eligijus

      Hello,

      I'm porting QWidget library to QQuickItem. Important to note that there are uses of QSharedPointer in library.
      I register class to access in qml qmlRegisterType() .
      Now my problem that I need to create and delete class object quite often and sometimes application crashes of segmentation fault. After following stack trace it leads to class destructor and QSharedPointer.

      So is QSharedPointer compatible with QML? And what are the solutions to incompatibility?

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Eligijus Did I understand correctly that you've got a class which inherits QQuickItem and has a QSharedPointer data member?

      What else handles the shared thing and in which way? Can you repeat the bug consistently? Have you debugged the program and the state of the pointer? Have you tried "Optional Pointer Tracking" for the pointer?

      Can you show at least the header, possibly the constructor if it does something with the pointer, and the destructor?

      E 1 Reply Last reply
      0
      • E Eeli K

        @Eligijus Did I understand correctly that you've got a class which inherits QQuickItem and has a QSharedPointer data member?

        What else handles the shared thing and in which way? Can you repeat the bug consistently? Have you debugged the program and the state of the pointer? Have you tried "Optional Pointer Tracking" for the pointer?

        Can you show at least the header, possibly the constructor if it does something with the pointer, and the destructor?

        E Offline
        E Offline
        Eligijus
        wrote on last edited by
        #3

        @Eeli-K said in QSharedPointer and QML:

        @Eligijus Did I understand correctly that you've got a class which inherits QQuickItem and has a QSharedPointer data member?

        Correct.

        What else handles the shared thing and in which way? Can you repeat the bug consistently? Have you debugged the program and the state of the pointer? Have you tried "Optional Pointer Tracking" for the pointer?

        Everything QSharedPointer is left for c++ to handle qml doesn't interfere.
        I first noticed it when I removed 3 unused random(not shared just int or anything else name type doesn't really matter) pointers from private then it crashed every time and adding them back seems to have fixed it. If I remove 1 unused pointer it crashed maybe from 2nd or 3rd time.

        Can you show at least the header, possibly the constructor if it does something with the pointer, and the destructor?

        I'm porting this library http://www.qcustomplot.com/index.php/download

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

          Hi,

          It would also be useful if we could take a look at the code you wrote to port that library.

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

          E 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            It would also be useful if we could take a look at the code you wrote to port that library.

            E Offline
            E Offline
            Eligijus
            wrote on last edited by
            #5

            @SGaist Sure thing.
            My port.
            I guess one would be the most intrested in this commit.

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

              Why not create a new class rather than changing the original QWidget based class ?

              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

              • Login

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