File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1212namespace nativeapi {
1313
1414WindowManager::WindowManager () {
15- // Initialize GTK if not already initialized (check if default display exists)
15+ // Try to initialize GTK if not already initialized
16+ // In headless environments, this may fail, which is acceptable
1617 if (!gdk_display_get_default ()) {
17- gtk_init (nullptr , nullptr );
18+ // Temporarily redirect stderr to suppress GTK warnings in headless environments
19+ FILE* original_stderr = stderr;
20+ freopen (" /dev/null" , " w" , stderr);
21+
22+ gboolean gtk_result = gtk_init_check (nullptr , nullptr );
23+
24+ // Restore stderr
25+ fflush (stderr);
26+ freopen (" /dev/tty" , " w" , stderr);
27+ stderr = original_stderr;
28+
29+ // gtk_init_check returns FALSE if initialization failed (e.g., no display)
30+ // This is acceptable for headless environments
1831 }
1932}
2033
You can’t perform that action at this time.
0 commit comments