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. How to track down detaching of QImage
Forum Updated to NodeBB v4.3 + New Features

How to track down detaching of QImage

Scheduled Pinned Locked Moved Unsolved General and Desktop
qimagedetachperfo
2 Posts 2 Posters 1.2k 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.
  • A Offline
    A Offline
    alan73
    wrote on last edited by
    #1

    Is there a way to track down when QImage is doing detaching (full copy of data, implicit shared paragidm)? Motivation is that I've found out a lot of memcpy() calls while analyzing performance and now I'm going to find out in what places of my code I use QImage wrong way that causes detaching.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You'd need to modify Qt code to print some message when detach happens. But you will get a lot of these messages, as implicit sharing is used everywhere (all container classes, plus many more general Qt classes). You can use clazy tool to get some hints of inefficient use of shared classes, I think.

      One good rule of thumb is - if you pass QImage (or any other implicitly shared class) into a function, always use const reference:

      void someMethod(const QImage &image);
      

      Also, be careful when using ranged for loop, it can detach if container is not const.

      (Z(:^

      1 Reply Last reply
      2

      • Login

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