Do not allow the manual insertion of a directory (without filename) into the import dialog and thus prevent an assertion.

Fixes: #7437
This commit is contained in:
Juergen Spitzmueller 2014-03-23 13:31:21 +01:00 committed by Richard Heck
parent 9b6eea6ca5
commit df1dbe28ce

View File

@ -2121,6 +2121,18 @@ void GuiView::importDocument(string const & argument)
// get absolute path of file // get absolute path of file
FileName const fullname(support::makeAbsPath(filename)); FileName const fullname(support::makeAbsPath(filename));
// Can happen if the user entered a path into the dialog
// (see bug #7437)
if (fullname.onlyFileName().empty()) {
docstring msg = bformat(_("The file name '%1$s' is invalid!\n"
"Aborting import."),
from_utf8(fullname.absFileName()));
frontend::Alert::error(_("File name error"), msg);
message(_("Canceled."));
return;
}
FileName const lyxfile(support::changeExtension(fullname.absFileName(), ".lyx")); FileName const lyxfile(support::changeExtension(fullname.absFileName(), ".lyx"));
// Check if the document already is open // Check if the document already is open