call gtk_init() before gtk_settings_get_default() to avoid Q_ASSERT triggering (#173)

As stated in GTK documentation about gtk_init():

* "Call this function before using any other GTK+ functions in your GUI
applications. It will initialize everything needed to operate the toolkit
and parses some standard command line options."

* "It is possible to pass NULL if argv is not available or commandline
handling is not required."

Fixes: #170
This commit is contained in:
trbogdanov 2022-10-31 04:39:43 +03:00 committed by GitHub
parent 4c88bc5ab2
commit 78638a3e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -43,6 +43,9 @@
#endif
#include <QtCore/qmutex.h>
#include <QtGui/qguiapplication.h>
#ifdef Q_OS_LINUX
# include <gtk/gtk.h>
#endif
#ifndef COMPILER_STRING
# ifdef Q_CC_CLANG // Must be before GNU, because Clang claims to be GNU too.
@ -111,6 +114,10 @@ void initialize()
}
inited = true;
#ifdef Q_OS_LINUX
gtk_init(nullptr, nullptr);
#endif
#ifdef Q_OS_LINUX
// Qt's Wayland experience is not good, so we force the XCB backend here.
// TODO: Remove this hack once Qt's Wayland implementation is good enough.