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

Assigning a new QObject w/o a parent to a C++ property through QML doesn't prevent it from being garbage collected

    XMLWordPrintable

Details

    Description

      A newly created QObject returned from a Q_INVOKABLE function that is bound to a property of a QObject derived class in QML and has no parent, is garbage collected while still being in use.

      See the attached example code.

      Environment
      Qt 5.13.1 (x86_64-little_endian-lp64 static release build; by Clang 10.0.0 (clang-1000.11.45.5) (Apple)) on "cocoa" 
      OS: macOS Mojave (10.14) [darwin version 18.7.0]
      
      Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX2 RTM HLE
      
      Environment:
      
      Features: QT_NO_EXCEPTIONS QT_NO_OPENSSL
      
      Library info:
        PrefixPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static
        DocumentationPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/doc
        HeadersPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/include
        LibrariesPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/lib
        LibraryExecutablesPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/libexec
        BinariesPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/bin
        PluginsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/plugins
        ImportsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/imports
        Qml2ImportsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/qml
        ArchDataPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static
        DataPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static
        TranslationsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/translations
        ExamplesPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/examples
        TestsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/tests
        SettingsPath: /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static
      
      Standard paths [*...* denote writable entry]:
        DesktopLocation: "Desktop" */Users/marcel.gotsch/Desktop*
        DocumentsLocation: "Documents" */Users/marcel.gotsch/Documents*
        FontsLocation: "Fonts" */Users/marcel.gotsch/Library/Fonts* /Library/Fonts /System/Library/Fonts
        ApplicationsLocation: "Applications" */Users/marcel.gotsch/Applications* /Applications
        MusicLocation: "Music" */Users/marcel.gotsch/Music*
        MoviesLocation: "Movies" */Users/marcel.gotsch/Movies*
        PicturesLocation: "Pictures" */Users/marcel.gotsch/Pictures*
        TempLocation: "Temporary Items" */private/var/folders/gw/0qbk28r94gl6rxnq0xklf6lc0000gp/T*
        HomeLocation: "Home" */Users/marcel.gotsch*
        AppLocalDataLocation: "Application Support" */Users/marcel.gotsch/Library/Application Support/QtProject/qtdiag* /Library/Application Support/QtProject/qtdiag /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/bin
        CacheLocation: "Caches" */Users/marcel.gotsch/Library/Caches/QtProject/qtdiag* /Library/Caches/QtProject/qtdiag
        GenericDataLocation: "Application Support" */Users/marcel.gotsch/Library/Application Support* /Library/Application Support
        RuntimeLocation: "Application Support" */Users/marcel.gotsch/Library/Application Support*
        ConfigLocation: "Preferences" */Users/marcel.gotsch/Library/Preferences*
        DownloadLocation: "Downloads" */Users/marcel.gotsch/Downloads*
        GenericCacheLocation: "Caches" */Users/marcel.gotsch/Library/Caches* /Library/Caches /System/Library/Caches
        GenericConfigLocation: "Preferences" */Users/marcel.gotsch/Library/Preferences*
        AppDataLocation: "Application Support" */Users/marcel.gotsch/Library/Application Support/QtProject/qtdiag* /Library/Application Support/QtProject/qtdiag /Users/marcel.gotsch/Developer/repos/3rdparty/Qt/Qt-5.13.1-R1-macx-clang-static/bin
        AppConfigLocation: "Preferences" */Users/marcel.gotsch/Library/Preferences/QtProject/qtdiag*
      
      File selectors (increasing order of precedence):
        en_US unix darwin mac osx macos
      
      Network:
        Using "Secure Transport, macOS Mojave (10.14)", version: 0x0
      
      Platform capabilities: ThreadedPixmaps OpenGL BufferQueueingOpenGL WindowMasks MultipleWindows ApplicationState ForeignWindows NonFullScreenWindows NativeWidgets WindowManagement RasterGLSurface ApplicationIcon
      
      Style hints:
        mouseDoubleClickInterval: 400
        mousePressAndHoldInterval: 800
        startDragDistance: 10
        startDragTime: 500
        startDragVelocity: 0
        keyboardInputInterval: 400
        keyboardAutoRepeatRate: 30
        cursorFlashTime: 1000
        showIsFullScreen: 0
        showIsMaximized: 0
        passwordMaskDelay: 0
        passwordMaskCharacter: U+2022
        fontSmoothingGamma: 2
        useRtlExtensions: 0
        setFocusOnTouchRelease: 0
        tabFocusBehavior: Qt::TabFocusAllControls 
        singleClickActivation: 0
      
      Additional style hints (QPlatformIntegration):
        ReplayMousePressOutsidePopup: 1
      
      Theme:
        Platforms requested : cocoa
                  available : 
        Styles requested    : macintosh
               available    : macintosh,Windows,Fusion
        System font         : ".SF NS Text" 13
        Native file dialog
        Native color dialog
        Native font dialog
      
      Fonts:
        General font : ".SF NS Text" 13
        Fixed font   : "Monaco" 10
        Title font   : ".SF NS Text" 13
        Smallest font: ".SF NS Text" 9
      
      Palette:
        QPalette::WindowText: #d8ffffff
        QPalette::Button: #ff323232
        QPalette::Light: #ff373737
        QPalette::Midlight: #ff343434
        QPalette::Dark: #ffbfbfbf
        QPalette::Mid: #ff232323
        QPalette::Text: #d8ffffff
        QPalette::BrightText: #ff373737
        QPalette::ButtonText: #ff000000
        QPalette::Base: #ff1e1e1e
        QPalette::Window: #ff323232
        QPalette::Shadow: #ff000000
        QPalette::Highlight: #ff3f638b
        QPalette::HighlightedText: #d8ffffff
        QPalette::Link: #ff0000ff
        QPalette::LinkVisited: #ffff00ff
        QPalette::AlternateBase: #ff989898
        QPalette::NoRole: #ff000000
        QPalette::ToolTipBase: #3fffffff
        QPalette::ToolTipText: #ff000000
        QPalette::PlaceholderText: #80ffffff
      
      Screens: 2, High DPI scaling: inactive
      # 0 "" Depth: 24 Primary: yes
        Manufacturer: 
        Model: 
        Serial number: 
        Geometry: 2560x1440+0+0 Available: 2560x1417+0+23
        Virtual geometry: 4480x1440-1920+0 Available: 4480x1417-1920+23
        2 virtual siblings
        Physical size: 599.3x340.242 mm  Refresh: 60 Hz Power state: 0
        Physical DPI: 108.5,107.5 Logical DPI: 72,72 Subpixel_RGB
        DevicePixelRatio: 2 Pixel density: 1
        Primary orientation: 2 Orientation: 2 Native orientation: 0 OrientationUpdateMask: 0
      
      # 1 "DELL P2217H" Depth: 24 Primary: no
        Manufacturer: 
        Model: 
        Serial number: 
        Geometry: 1920x1080-1920+174 Available: 1920x1057-1920+197
        Virtual geometry: 4480x1440-1920+0 Available: 4480x1417-1920+23
        2 virtual siblings
        Physical size: 478.118x266.33 mm  Refresh: 60 Hz Power state: 0
        Physical DPI: 102,103 Logical DPI: 72,72 Subpixel_RGB
        DevicePixelRatio: 1 Pixel density: 1
        Primary orientation: 2 Orientation: 2 Native orientation: 0 OrientationUpdateMask: 0
      
      LibGL Vendor: ATI Technologies Inc.
      Renderer: AMD Radeon Pro 580 OpenGL Engine
      Version: 2.1 ATI-2.11.21
      Shading language: 1.20
      Format: Version: 2.1 Profile: 0 Swap behavior: 2 Buffer size (RGB): 8,8,8
      Profile: None (QOpenGLFunctions_5710346_1)
      
      

       

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              marcel.gotsch Marcel Gotsch
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes