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
This commit is contained in:
John Scipione 2016-08-16 14:55:36 -07:00
parent e85c33517c
commit 14698e0432

View File

@ -133,17 +133,23 @@ KeymapWindow::KeymapWindow()
path.Append("Keymap");
entry_ref ref;
get_ref_for_path(path.Path(), &ref);
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);
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);
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);
}
BRect windowFrame;
BString keyboardLayout;