Strange memory allocation in Qt for Android



  • 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?


  • Lifetime Qt Champion

    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.



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.