Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Initialize X11 threading for Auth

Neeraj Gupta0a4236bd82e6
diff --git a/mobile/apps/auth/changes/linux-x11-threading.md b/mobile/apps/auth/changes/linux-x11-threading.md
new file mode 100644
index 0000000000..87c17a56d9
--- /dev/null
+++ b/mobile/apps/auth/changes/linux-x11-threading.md
@@ -0,0 +1 @@
+- Fixed Auth startup crashes on Linux X11 sessions caused by Xlib threading initialization.
diff --git a/mobile/apps/auth/linux/CMakeLists.txt b/mobile/apps/auth/linux/CMakeLists.txt
index f9f9eab9b6..67ba5aabf1 100644
--- a/mobile/apps/auth/linux/CMakeLists.txt
+++ b/mobile/apps/auth/linux/CMakeLists.txt
@@ -55,6 +55,7 @@ add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
+pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
@@ -75,6 +76,7 @@ apply_standard_settings(${BINARY_NAME})
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
+target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::X11)
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
diff --git a/mobile/apps/auth/linux/main.cc b/mobile/apps/auth/linux/main.cc
index e7c5c54370..2a0ad96809 100644
--- a/mobile/apps/auth/linux/main.cc
+++ b/mobile/apps/auth/linux/main.cc
@@ -1,6 +1,13 @@
#include "my_application.h"
+#ifdef GDK_WINDOWING_X11
+#include <X11/Xlib.h>
+#endif
+
int main(int argc, char** argv) {
+#ifdef GDK_WINDOWING_X11
+ XInitThreads();
+#endif
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}