Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20347

QStringList -> NSMutableArray conversion memory leak

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 4.7.3
    • Fix Version/s: 5.3.0
    • Labels:
      None
    • Environment:
      Mac OS X 10.6.8
    • Commits:
      66178447e91f56eaeaee203171b9355399d3bb5c

      Description

      NSString not released after it is added to the NSMutableArray.

      The code we have in qt_cocoa_helpers_mac.mm

      void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
      {
          NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.size()];
          for (int i=0; i<list.size(); ++i){
              [result addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(list[i]))]; //Here is a leak!
          }
          return result;
      }
      

      It should use another function from the helper to do the QString -> NSString conversion:

      void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
      {
          NSMutableArray *result = [NSMutableArray arrayWithCapacity:list.size()];
          for (int i=0; i<list.size(); ++i){
              [result addObject:qt_mac_QStringToNSString(list[i])]; //Now leak is gone!(If the autorelease pool is used, but I think it is)
          }
          return result;
      }
      

      the same is applicable for -(void)registerDragTypes in qcocoasharedwindowmethods_mac_p.h and maybe for other places which I didn't find.

      P.S. Leak was found with Instruments tool.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sorvig Morten Sørvig
            Reporter:
            ixsci Eugene Shcherbina
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes