Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Strange memory allocation in Qt for Android
Qt 6.11 is out! See what's new in the release blog

Strange memory allocation in Qt for Android

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 2.1k 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
    Adonai
    wrote on last edited by
    #1

    Sources of clipboard for android:

    @QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode)
    {
    ...

    QMimeData *mimeData = new QMimeData();
    mimeData->setText(QtAndroidClipboard::clipboardText());
    return mimeData;
    

    }@

    Is there a memory leak? On all other platforms that method returns pointer to class field.

    Next, qandroidplatformintegration.h/cpp:

    header:
    @...
    private:
    QPlatformClipboard *m_androidPlatformClipboard;
    ...@

    constructor:
    @...
    m_androidPlatformClipboard = new QAndroidPlatformClipboard();
    ...@

    no sign of presence of this field anywhere else - neither in destructor, neither in function that returns clipboard:

    @QPlatformClipboard *QAndroidPlatformIntegration::clipboard() const
    {
    static QAndroidPlatformClipboard *clipboard = 0;
    if (!clipboard)
    clipboard = new QAndroidPlatformClipboard;

    return clipboard;
    

    }@

    Am I novice, or are there memory leaks around?

    Calamity from the skies

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

      Hi and welcome to devnet,

      For the first point, it's not necessarily a bug, the handling might be done differently on Android. However I encourage you to ask this on the developer mailing list you'll find Qt's developers/maintainers there (this forum is more user oriented)

      For the second point, indeed, the clipboard is allocated twice and not deleted in the destructor in the case of the member variable. A patch for that has been submitted.

      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
      • A Offline
        A Offline
        Adonai
        wrote on last edited by
        #3

        Thanks!

        [quote author="SGaist" date="1390087124"]
        For the second point, indeed, the clipboard is allocated twice and not deleted in the destructor in the case of the member variable. A patch for that has been submitted.[/quote]

        Yep, I already commented "bugreport":https://bugreports.qt-project.org/browse/QTBUG-36025 existed previously.

        Calamity from the skies

        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