trying to fix crash in FileDialog on failed opening of directory

This commit is contained in:
Vadim Lopatin 2017-08-25 17:58:23 +03:00
parent 9244f8aaed
commit c16c69c344
1 changed files with 7 additions and 4 deletions

View File

@ -264,9 +264,10 @@ class FileDialog : Dialog, CustomGridCellAdapter {
try { try {
_entries = listDirectory(dir, attrFilter, selectedFilter()); _entries = listDirectory(dir, attrFilter, selectedFilter());
} catch(Exception e) { } catch(Exception e) {
import dlangui.dialogs.msgbox; Log.e("Cannot list directory " ~ dir, e);
auto msgBox = new MessageBox(UIString.fromId("MESSAGE_ERROR"c), UIString.fromRaw(e.msg.toUTF32), window()); //import dlangui.dialogs.msgbox;
msgBox.show(); //auto msgBox = new MessageBox(UIString.fromId("MESSAGE_ERROR"c), UIString.fromRaw(e.msg.toUTF32), window());
//msgBox.show();
return false; return false;
} }
_fileList.rows = 0; _fileList.rows = 0;
@ -664,8 +665,10 @@ class FileDialog : Dialog, CustomGridCellAdapter {
onItemSelected(row); onItemSelected(row);
}; };
if (_path.empty) { if (_path.empty || !_path.isDir) {
_path = currentDir; _path = currentDir;
if (!_path.isDir)
_path = homePath;
} }
openDirectory(_path, _filename); openDirectory(_path, _filename);
_fileList.layoutHeight = FILL_PARENT; _fileList.layoutHeight = FILL_PARENT;