gtk3: Disable native file dialogs on GTK3 < 3.15.5
Showing file dialogs if running on a system that has an older GTK3 version installed results in a crash. Do a version check at runtime and disable native file dialog support if the version is too old. (GTK3 bug: https://bugzilla.gnome.org/show_bug.cgi?id=725164) Change-Id: I77bd23f1298333412bae04f52153e1a224ddf470 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>bb10
parent
1aae404a4c
commit
2b47afadc0
|
|
@ -153,7 +153,7 @@ bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
|
|||
case ColorDialog:
|
||||
return true;
|
||||
case FileDialog:
|
||||
return true;
|
||||
return useNativeFileDialog();
|
||||
case FontDialog:
|
||||
return true;
|
||||
default:
|
||||
|
|
@ -167,6 +167,8 @@ QPlatformDialogHelper *QGtk3Theme::createPlatformDialogHelper(DialogType type) c
|
|||
case ColorDialog:
|
||||
return new QGtk3ColorDialogHelper;
|
||||
case FileDialog:
|
||||
if (!useNativeFileDialog())
|
||||
return nullptr;
|
||||
return new QGtk3FileDialogHelper;
|
||||
case FontDialog:
|
||||
return new QGtk3FontDialogHelper;
|
||||
|
|
@ -185,4 +187,17 @@ QPlatformMenuItem* QGtk3Theme::createPlatformMenuItem() const
|
|||
return new QGtk3MenuItem;
|
||||
}
|
||||
|
||||
bool QGtk3Theme::useNativeFileDialog()
|
||||
{
|
||||
/* Require GTK3 >= 3.15.5 to avoid running into this bug:
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=725164
|
||||
*
|
||||
* While this bug only occurs when using widget-based file dialogs
|
||||
* (native GTK3 dialogs are fine) we have to disable platform file
|
||||
* dialogs entirely since we can't avoid creation of a platform
|
||||
* dialog helper.
|
||||
*/
|
||||
return gtk_check_version(3, 15, 5) == 0;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ public:
|
|||
QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE;
|
||||
|
||||
static const char *name;
|
||||
private:
|
||||
static bool useNativeFileDialog();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue