@@ -238,7 +238,7 @@ RetVal<INotationProjectPtr> ProjectActionsController::loadProject(const io::path
238
238
return ret;
239
239
}
240
240
241
- if (checkCanIgnoreError (ret, io::filename ( loadPath). toString () )) {
241
+ if (checkCanIgnoreError (ret, loadPath)) {
242
242
ret = project->load (loadPath, " " /* stylePath*/ , true /* forceMode*/ , format);
243
243
}
244
244
@@ -1375,7 +1375,7 @@ void ProjectActionsController::showScoreDownloadError(const Ret& ret)
1375
1375
interactive ()->warning (title, message);
1376
1376
}
1377
1377
1378
- bool ProjectActionsController::checkCanIgnoreError (const Ret& ret, const String& projectName )
1378
+ bool ProjectActionsController::checkCanIgnoreError (const Ret& ret, const io:: path_t & filepath )
1379
1379
{
1380
1380
if (ret) {
1381
1381
return true ;
@@ -1387,11 +1387,16 @@ bool ProjectActionsController::checkCanIgnoreError(const Ret& ret, const String&
1387
1387
case engraving::Err::FileOld300Format:
1388
1388
return askIfUserAgreesToOpenProjectWithIncompatibleVersion (ret.text ());
1389
1389
case engraving::Err::FileCorrupted:
1390
- return askIfUserAgreesToOpenCorruptedProject (projectName , ret.text ());
1391
- default :
1392
- warnProjectCannotBeOpened (projectName , ret.text ());
1390
+ return askIfUserAgreesToOpenCorruptedProject (io::filename (filepath). toString () , ret.text ());
1391
+ case engraving::Err::FileCriticallyCorrupted :
1392
+ warnProjectCriticallyCorrupted ( io::filename (filepath). toString () , ret.text ());
1393
1393
return false ;
1394
+ default :
1395
+ break ;
1394
1396
}
1397
+
1398
+ warnProjectCannotBeOpened (ret, filepath);
1399
+ return false ;
1395
1400
}
1396
1401
1397
1402
bool ProjectActionsController::askIfUserAgreesToOpenProjectWithIncompatibleVersion (const std::string& errorText)
@@ -1421,7 +1426,7 @@ bool ProjectActionsController::askIfUserAgreesToOpenCorruptedProject(const Strin
1421
1426
return btn == openAnywayBtn.btn ;
1422
1427
}
1423
1428
1424
- void ProjectActionsController::warnProjectCannotBeOpened (const String& projectName, const std::string& errorText)
1429
+ void ProjectActionsController::warnProjectCriticallyCorrupted (const String& projectName, const std::string& errorText)
1425
1430
{
1426
1431
std::string title = mtrc (" project" , " File “%1” is corrupted and cannot be opened" ).arg (projectName).toStdString ();
1427
1432
std::string body = trc (" project" , " Get help for this issue on musescore.org." );
@@ -1438,6 +1443,29 @@ void ProjectActionsController::warnProjectCannotBeOpened(const String& projectNa
1438
1443
}
1439
1444
}
1440
1445
1446
+ void ProjectActionsController::warnProjectCannotBeOpened (const Ret& ret, const io::path_t & filepath)
1447
+ {
1448
+ std::string title = mtrc (" project" , " Cannot read file %1" ).arg (filepath.toString ()).toStdString ();
1449
+ std::string body;
1450
+
1451
+ switch (ret.code ()) {
1452
+ case int (engraving::Err::FileNotFound):
1453
+ body = trc (" project" , " This file does not exist or cannot be accessed currently." );
1454
+ break ;
1455
+ case int (engraving::Err::FileOpenError):
1456
+ body = trc (" project" , " This file could not be opened. Please make sure that MuseScore has permission to read this file." );
1457
+ break ;
1458
+ default :
1459
+ if (!ret.text ().empty ()) {
1460
+ body = ret.text ();
1461
+ } else {
1462
+ body = trc (" project" , " An error occurred while reading this file." );
1463
+ }
1464
+ }
1465
+
1466
+ interactive ()->error (title, body);
1467
+ }
1468
+
1441
1469
void ProjectActionsController::importPdf ()
1442
1470
{
1443
1471
interactive ()->openUrl (" https://musescore.com/import" );
0 commit comments