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

Native GTK+ 3.x dialogs: improper signal emission

    XMLWordPrintable

Details

    • b2799062f365fb1d4c9820d33fd38cf5510d2ade

    Description

      ColorDialog:

      • QGtk3ColorDialogHelper::currentColorChanged() is NOT emitted while selecting colors
      • QColorDialog::colorSelected() emitted TWICE on accept
      • QML ColorDialog.color is not updated on accept

      FontDialog:

      • QGtk3FontDialogHelper::currentFontChanged() is NOT emitted while selecting fonts
      • QFontDialog::fontSelected() emitted TWICE on accept
      • QML FontDialog.font follows currentFont (should be updated on accept instead)

      FileDialog:

      • QFileDialog::file(s)Selected() emitted TWICE on accept
      • QML FileDialog.filterSelected() only emitted on accept

      Side-note:

      • A missing null check in QGtk3Dialog::show() causes QObject::connect: invalid null parameter -warnings with the widget-based test case below.

      A test case with QtWidgets dialogs:

      #include <QtWidgets>
      
      //#define DONT_USE_NATIVE_DIALOGS
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QColorDialog colorDialog;
      #ifdef DONT_USE_NATIVE_DIALOGS
          colorDialog.setOption(QColorDialog::DontUseNativeDialog);
      #endif
          QObject::connect(&colorDialog, &QColorDialog::colorSelected, [](const QColor &c) { qDebug() << "QColorDialog::colorSelected" << c; });
          QObject::connect(&colorDialog, &QColorDialog::currentColorChanged, [](const QColor &c) { qDebug() << "QColorDialog::currentColorChanged" << c; });
          colorDialog.show();
      
          QFontDialog fontDialog;
      #ifdef DONT_USE_NATIVE_DIALOGS
          fontDialog.setOption(QFontDialog::DontUseNativeDialog);
      #endif
          QObject::connect(&fontDialog, &QFontDialog::fontSelected, [](const QFont &f) { qDebug() << "QFontDialog::fontSelected" << f; });
          QObject::connect(&fontDialog, &QFontDialog::currentFontChanged, [](const QFont &f) { qDebug() << "QFontDialog::currentFontChanged" << f; });
          fontDialog.show();
      
          QFileDialog fileDialog;
      #ifdef DONT_USE_NATIVE_DIALOGS
          fileDialog.setOption(QFileDialog::DontUseNativeDialog);
      #endif
          QObject::connect(&fileDialog, &QFileDialog::fileSelected, [](const QString &f) { qDebug() << "QFileDialog::fileSelected" << f; });
          QObject::connect(&fileDialog, &QFileDialog::currentChanged, [](const QString &f) { qDebug() << "QFileDialog::currentChanged" << f; });
          QObject::connect(&fileDialog, &QFileDialog::directoryEntered, [](const QString &f) { qDebug() << "QFileDialog::directoryEntered" << f; });
          fileDialog.show();
      
          return app.exec();
      }
      

      When DONT_USE_NATIVE_DIALOGS is defined, it uses QWidget based dialogs instead, and then the behavior is correct.

      A test case with QtQuick Dialogs:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Dialogs 1.2
      
      Window {
          width: 640
          height: 480
          visible: false
      
          ColorDialog {
              visible: true
              onColorChanged: console.log("onColorChanged:", color)
              onCurrentColorChanged: console.log("onCurrentColorChanged:", currentColor)
          }
      
          FontDialog {
              visible: true
              onFontChanged: console.log("onFontChanged:", font)
              onCurrentFontChanged: console.log("onCurrentFontChanged:", currentFont)
          }
      
          FileDialog {
              visible: true
              onFileUrlChanged: console.log("onFileUrlChanged:", fileUrl)
              onFileUrlsChanged: console.log("onFileUrlsChanged:", fileUrls)
          }
      }
      

      QtQuick Dialogs don't suffer from the duplicate "selected" signals, because they are wired to a property, but the "currentChanged" notifiers are missing just like with QtWidgets.

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              jpnurmi J-P Nurmi
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: