Use a better workaround for Wayland crashes.

GoldenDict use lots of X11 functions and it currently cannot work natively on Wayland. This workaround will force GoldenDict to use  XWayland.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
This commit is contained in:
Vitaly Zaitsev 2020-03-27 11:08:52 +01:00
parent db93bd19d3
commit 6ca112b797
No known key found for this signature in database
GPG key ID: BF99FC6DD45AB90A
2 changed files with 11 additions and 5 deletions

11
main.cc
View file

@ -212,6 +212,17 @@ public:
int main( int argc, char ** argv ) int main( int argc, char ** argv )
{ {
#ifdef Q_OS_UNIX
// GoldenDict use lots of X11 functions and it currently cannot work
// natively on Wayland. This workaround will force GoldenDict to use
// XWayland.
char * xdg_envc = getenv("XDG_SESSION_TYPE");
QString xdg_session = xdg_envc ? QString::fromLatin1(xdg_envc) : QString();
if (!QString::compare(xdg_session, QString("wayland"), Qt::CaseInsensitive))
{
setenv("QT_QPA_PLATFORM", "xcb", 1);
}
#endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setenv("LANG", "en_US.UTF-8", 1); setenv("LANG", "en_US.UTF-8", 1);

View file

@ -7,8 +7,3 @@ GenericName=Multiformat Dictionary
Comment=GoldenDict Comment=GoldenDict
Icon=goldendict Icon=goldendict
Exec=goldendict Exec=goldendict
Actions=X11;
[Desktop Action X11]
Name=GoldenDict (X11)
Exec=env QT_QPA_PLATFORM=xcb goldendict