Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. QSharedDataPointer detach too much ( don't call const )
Qt 6.11 is out! See what's new in the release blog

QSharedDataPointer detach too much ( don't call const )

Scheduled Pinned Locked Moved Unsolved C++ Gurus
2 Posts 2 Posters 928 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 Offline
    M Offline
    miskol
    wrote on last edited by
    #1

    Hello
    example
    https://pastebin.com/xL9yWhKe

    I never used QSharedDataPointer in my code but is is heavily used in Qt
    My problem is that I found that QSharedDataPointer prefer non const operator for access raw pointer to object instead of const variant.
    And at the end non const variant call detach() = cloning object
    Look at my example and plz debug if conditions

    I use compiler MSVC 2015, 2017

    My problem is that for example QTextCursor use this constructions and it heavily call detach. And simple call const variant of method should fix this.

    Anybody can explain this behaviour?

    jsulmJ 1 Reply Last reply
    0
    • M miskol

      Hello
      example
      https://pastebin.com/xL9yWhKe

      I never used QSharedDataPointer in my code but is is heavily used in Qt
      My problem is that I found that QSharedDataPointer prefer non const operator for access raw pointer to object instead of const variant.
      And at the end non const variant call detach() = cloning object
      Look at my example and plz debug if conditions

      I use compiler MSVC 2015, 2017

      My problem is that for example QTextCursor use this constructions and it heavily call detach. And simple call const variant of method should fix this.

      Anybody can explain this behaviour?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @miskol It outputs 2 times "bbb". Why do you think there is a detach in your example?

      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