Skip to content

Commit 82759c2

Browse files
committed
System File Chooser on Linux: check whether required GSettings schemas are installed to avoid application crash (issue #1069)
occurred on NixOS with Plasma (KDE) desktop
1 parent edda520 commit 82759c2

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ FlatLaf Change Log
33

44
## 3.7.1-SNAPSHOT
55

6-
- System File Chooser: Update current filter before invoking approve callback
7-
and after closing dialog. (issue #1065)
6+
- System File Chooser:
7+
- Update current filter before invoking approve callback and after closing
8+
dialog. (issue #1065)
9+
- On Linux: Check whether required GSettings schemas are installed to avoid
10+
application crash (occurred on NixOS with Plasma/KDE desktop). (issue #1069)
811
- ComboBox: Added UI property `ComboBox.buttonFocusedEditableBackground`. (issue
912
#1068)
1013
- Popup: Fixed scrolling popup painting issue on Windows 10 when a glass pane is

flatlaf-natives/flatlaf-natives-linux/src/main/cpp/GtkFileChooser.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ extern Window getWindowHandle( JNIEnv* env, JAWT* awt, jobject window, Display**
3333
// declare internal methods
3434
static jobjectArray fileListToStringArray( JNIEnv* env, GSList* fileList );
3535

36+
// fields
37+
static int settingsSchemaInstalled = -1;
38+
3639
//---- helper -----------------------------------------------------------------
3740

3841
#define isOptionSet( option ) ((optionsSet & com_formdev_flatlaf_ui_FlatNativeLinuxLibrary_ ## option) != 0)
@@ -188,6 +191,22 @@ JNIEXPORT jobjectArray JNICALL Java_com_formdev_flatlaf_ui_FlatNativeLinuxLibrar
188191
if( !gtk_init_check( NULL, NULL ) )
189192
return NULL;
190193

194+
// check whether required GSettings schemas are installed (e.g. on NixOS)
195+
// this avoids output of following message on console, followed by an application crash:
196+
// GLib-GIO-ERROR: No GSettings schemas are installed on the system
197+
if( settingsSchemaInstalled < 0 ) {
198+
GSettingsSchemaSource* schemaSource = g_settings_schema_source_get_default();
199+
GSettingsSchema* schema = (schemaSource != NULL)
200+
? g_settings_schema_source_lookup( schemaSource, "org.gtk.Settings.FileChooser", FALSE )
201+
: NULL;
202+
if( schema != NULL )
203+
g_settings_schema_unref( schema );
204+
205+
settingsSchemaInstalled = (schema != NULL);
206+
}
207+
if( settingsSchemaInstalled <= 0 )
208+
return NULL;
209+
191210
// convert Java strings to C strings
192211
AutoReleaseStringUTF8 ctitle( env, title );
193212
AutoReleaseStringUTF8 cokButtonLabel( env, okButtonLabel );

0 commit comments

Comments
 (0)