Hi John,
Am 17.08.2016 um 00:02 schrieb jscipione@xxxxxxxxx:
1 file changed, 22 insertions(+), 14 deletions(-)
src/preferences/keymap/KeymapWindow.cpp | 36 ++++++++++++++++++-----------
############################################################################
Commit: 14698e043233c4fb0f783993d0c874c8241eff77
URL: http://cgit.haiku-os.org/haiku/commit/?id=14698e043233
Author: John Scipione <jscipione@xxxxxxxxx>
Date: Tue Aug 16 21:55:36 2016 UTC
Keymap: Check return value of get_ref_for_path
if not B_OK, create BFilePanels with default directory
This should never happen but better than crashing on a NULL ref
----------------------------------------------------------------------------
diff --git a/src/preferences/keymap/KeymapWindow.cpp
b/src/preferences/keymap/KeymapWindow.cpp
index a8a8459..cb93cae 100644
--- a/src/preferences/keymap/KeymapWindow.cpp
+++ b/src/preferences/keymap/KeymapWindow.cpp
@@ -133,17 +133,23 @@ KeymapWindow::KeymapWindow()
path.Append("Keymap");
entry_ref ref;
- get_ref_for_path(path.Path(), &ref);
-
- BDirectory userKeymapsDir(&ref);
- if (userKeymapsDir.InitCheck() != B_OK)
- create_directory(path.Path(), S_IRWXU | S_IRWXG | S_IRWXO);
-
- BMessenger messenger(this);
- fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, &ref,
- B_FILE_NODE, false, NULL);
- fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, &ref,
- B_FILE_NODE, false, NULL);
+ if (get_ref_for_path(path.Path(), &ref) == B_OK) {
+ BDirectory userKeymapsDir(&ref);
+ if (userKeymapsDir.InitCheck() != B_OK)
+ create_directory(path.Path(), S_IRWXU | S_IRWXG |
S_IRWXO);
+
+ BMessenger messenger(this);
+ fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, &ref,
+ B_FILE_NODE, false, NULL);
+ fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, &ref,
+ B_FILE_NODE, false, NULL);
+ } else {
+ BMessenger messenger(this);
+ fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
+ B_FILE_NODE, false, NULL);
+ fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
+ B_FILE_NODE, false, NULL);
+ }