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

crash in QHighDpiScaling::updateHighDpiScaling() if no screens are available

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.12.0
    • Fix Version/s: 5.12.2, 5.14.0 Alpha
    • Component/s: GUI: Workspace
    • Labels:
      None
    • Platform/s:
      Linux/Other display system
    • Commits:
      230921a7f00d368551ecf5d6457765eae03e9325 (qt/qtbase/5.12)

      Description

      I have an i.MX6 board with only egl backend. The application automatically start on boot and calls showMaximized() on a QQuickView. When no display is connected this crashes with a backtrace like this:

      #0  0xb632b534 in QScreen::handle() const () from /usr/lib/libQt5Gui.so.5
      #1  0xb633a290 in QHighDpiScaling::updateHighDpiScaling() ()
         from /usr/lib/libQt5Gui.so.5
      

      This patch solves it for the moment, although I'm not sure if this is the right way to handle it:

      --- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
      +++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
      @@ -313,7 +313,10 @@ void QHighDpiScaling::updateHighDpiScaling()
           }
           m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
       
      -    QPlatformScreen *primaryScreen = QGuiApplication::primaryScreen()->handle();
      +    auto ps = QGuiApplication::primaryScreen();
      +    if (ps == nullptr)
      +        return;
      +    QPlatformScreen *primaryScreen = ps->handle();
           qreal sf = screenSubfactor(primaryScreen);
           QDpi primaryDpi = primaryScreen->logicalDpi();
           m_logicalDpi = QDpi(primaryDpi.first / sf, primaryDpi.second / sf);
      

        Attachments

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

          Activity

            People

            Assignee:
            vestbo Tor Arne Vestbø
            Reporter:
            rebemlix Rolf Eike Beer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes