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

[REG 6.5.1->6.5.2] Setting a DockWidget title when the DockWidget is closed causes windowTitle to be null or desync

    XMLWordPrintable

Details

    • 92d837e68 (dev), 72e9795d4 (6.6), 75f310501 (6.5)

    Description

      In Qt 6.5.2 (and 6.5.3), if you attempt to set the windowTitle of a QDockWidget that has been closed, then get its windowTitle, you may get back an empty string. We ran into this in OBS Studio GitHub Pull Request 9373, where we discovered that Custom Browser Docks (BrowserDock, an implementation of QDockWidget containing a CEF window) would lose their set window titles. We were using the QDockWidgets to store the window titles, but found that if you tried to change the title of a QDockWidget that was closed (not hidden/minimized, but closed), then the next time we tried to read its window title, it would be NULL or empty.

      We determined the offending commit to be https://github.com/qt/qtbase/commit/c153066baaa88718ed45b68230d81285eb436d3d (https://codereview.qt-project.org/c/qt/qtbase/+/478108), which was merged to fix QTBUG-113591.

      Digging deeper, breakpoint inspection inside Qt revealed that when we called QDockWidget::setWindowTitle that windowHandle()->title() returns NULL in qdockwidget.cpp here:
      https://github.com/qt/qtbase/blob/v6.5.2/src/widgets/widgets/qdockwidget.cpp#L1479

      Similarly, d->fixedWindowTitle would be NULL here:
      https://github.com/qt/qtbase/blob/v6.5.2/src/widgets/widgets/qdockwidget.cpp#L1486

      Then toggleViewAction()->setText() passes that along, which is why we ended up with missing titles in OBS Studio:
      https://github.com/qt/qtbase/blob/v6.5.2/src/widgets/widgets/qdockwidget.cpp#L1487

      See the attached obs-studio-dockwidgets-windowtitle-01.png showing this call stack.

      We did discover that calling winId() in our BrowserDock constructor would remedy this behavior, but we were concerned about other side effects, so we opted to handle (re)storing the window titles manually instead of relying on QDockWidget to store that data.

      Steps to reproduce in OBS Studio are:

      1. Build OBS Studio at commit c7cba7f80338c5481de6403c8d1290f56272e672 (or download one of the assets from its GitHub Actions run).
        This is the commit before we applied workarounds.
      2. Open OBS Studio.
      3. In the menu bar, click Docks -> Custom Browser Docks...
      4. Define one (or more) browser docks.
      5. Click Apply.
        Note at this point that the browser dock will launch with a default title rather than the one specified.
      6. Change the title of the dock.
      7. In the menu bar, click Docks, and note the title of the Custom Browser Docks at the bottom is set.
      8. Note the title of the browser dock window is set.
      9. Close the browser dock.
      10. Close OBS.
      11. Open OBS.
      12. In the menu bar, click Docks, and note the title of the Custom Browser Docks at the bottom is missing.
      13. In the menu bar, click Docks -> Custom Browser Docks...
      14. Change the title of the dock.
      15. Click Apply.
      16. In the menu bar, click Docks, and note the titles of the Custom Browser Docks at the bottom is still missing.
      17. In the menu bar, click Docks, then click the blank space where the title should be.
      18. In the menu bar, click Docks -> Custom Browser Docks...
      19. Change the title of the dock.
      20. Click Apply.
      21. In the menu bar, click Docks, and note the title of the Custom Browser Docks at the bottom is set.
      22. Note the title of the browser dock window is set.

      If you take the above steps in OBS Studio 29.1.3 (or any commit before our workaround where you build against Qt 6.5.0 or 6.5.1), you should see the dock titles update without issue.

      I tried to reproduce this in a simpler Qt example. The closest that I got was hacking up the dockwidgets example. There, I can demonstrate that the windowTitle is not set when attempting to do so on a closed QDockWidget, though I could not get it to return a NULL or empty string as occurs in OBS Studio. For that example, see attached qt-examples-dockwidgets.zip.

      Steps to take in the example:

      1. Build the example with Qt 6.5.2 or 6.5.3 (newer versions will probably also work).
      2. Run the example.
      3. Make sure the QDockWidget Test Dock is visible.
      4. Click the "New Document" button ("Rename Test Dock").
      5. Note the windowTitle reporting in the main window.
      6. Close the Test Dock.
      7. Click the "New Document" button ("Rename Test Dock").
      8. Note that the windowTitle remains unchanged, but the index continues to increment.

      I realize this is a bit involved, so please do not hesitate to ask any questions or ask me to rebuild and debug in Visual Studio to look for more information.

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            rytoex Ryan Foster
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes