Show reason a file couldn't be loaded.

This commit is contained in:
Leonardo Zide 2019-03-10 13:41:21 -07:00
parent d0e411f0a5
commit d084d11b5a
3 changed files with 11 additions and 10 deletions

View file

@ -198,7 +198,7 @@ bool lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPaths, bool&
QString ModelName;
QString CameraName;
QString ViewpointName;
QString ProjectName = lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT) ? lcGetProfileString(LC_PROFILE_RECENT_FILE1) : QString();
QString ProjectName;
QString SaveWavefrontName;
QString Save3DSName;
QString SaveCOLLADAName;
@ -436,6 +436,9 @@ bool lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPaths, bool&
Project* NewProject = new Project();
SetProject(NewProject);
if (ShowWindow && ProjectName.isEmpty() && lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT))
ProjectName = lcGetProfileString(LC_PROFILE_RECENT_FILE1);
if (!ProjectName.isEmpty() && gMainWindow->OpenProject(ProjectName))
{
if (!ModelName.isEmpty())

View file

@ -931,11 +931,6 @@ void lcMainWindow::ProjectFileChanged(const QString& Path)
RestoreTabLayout(TabLayout);
UpdateAllViews();
}
else
{
QMessageBox::critical(this, tr("LeoCAD"), tr("Error loading '%1'.").arg(Path));
delete NewProject;
}
}
else
{
@ -2188,7 +2183,6 @@ bool lcMainWindow::OpenProject(const QString& FileName)
return true;
}
QMessageBox::critical(this, tr("LeoCAD"), tr("Error loading '%1'.").arg(LoadFileName));
delete NewProject;
return false;
@ -2223,8 +2217,6 @@ void lcMainWindow::MergeProject()
UpdateModels();
}
else
QMessageBox::critical(this, tr("LeoCAD"), tr("Error loading '%1'.").arg(LoadFileName));
delete NewProject;
}

View file

@ -355,7 +355,10 @@ bool Project::Load(const QString& FileName)
QFile File(FileName);
if (!File.open(QIODevice::ReadOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error reading file '%1':\n%2").arg(FileName, File.errorString()));
return false;
}
mModels.DeleteAll();
SetFileName(FileName);
@ -370,7 +373,7 @@ bool Project::Load(const QString& FileName)
else if (Extension == QLatin1String("lcd") || Extension == QLatin1String("leocad"))
LoadDAT = false;
else
LoadDAT = memcmp(FileData, "LeoCAD ", 7);
LoadDAT = FileData.size() > 7 && memcmp(FileData, "LeoCAD ", 7);
if (LoadDAT)
{
@ -419,7 +422,10 @@ bool Project::Load(const QString& FileName)
}
if (mModels.IsEmpty())
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error loading file '%1':\nFile format is not recognized.").arg(FileName));
return false;
}
if (mModels.GetSize() == 1)
{