qtApp.processEvents();//This is used to accept a click on the screen so that user can cancel the screen
#endif
//
// 1. Initialize application and sync settings.
//
// Coverity-14835
// {
mvd::Application*application=NULL;
try
{
application=newmvd::Application(&qtApp);
assert(application!=NULL);
application->Initialize();
}
catch(std::exception&exc)
{
QMessageBox::StandardButtonbutton=
QMessageBox::question(
NULL,
QCoreApplication::translate(
PROJECT_NAME,
"Question!"
),
QCoreApplication::translate(
PROJECT_NAME,
"The following exception has been caught while initializing the software:\n\n"
"%1\n\n"
"The application may not function as expected. Do you want to continue?"
)
.arg(exc.what()),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes
);
if(button==QMessageBox::No)
returnERROR_CODE_I18N;
}
// }
// Coverity-14835
//
// 2. Initialize main-window (UI).
mvd::MainWindowmainWindow;
mainWindow.Initialize();
//
// 3. Initialize cache directory.
try
{
mainWindow.SetupCacheDir();
}
catch(std::exception&exc)
{
QMessageBox::critical(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Critical error!"
),
QCoreApplication::translate(
PROJECT_NAME,
"Error while creating cache repository.\n\n"
"%1\n\n"
"Application will exit!"
)
.arg(exc.what())
);
returnERROR_CODE_CACHE_DIR;
}
//
// 4. Initialize database.
try
{
mvd::CountTypenb=application->OpenDatabase();
if(nb>0)
{
QMessageBox::StandardButtonbutton=
QMessageBox::warning(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Warning!"
),
QCoreApplication::translate(
PROJECT_NAME,
"There are %1 outdated dataset(s) in cache-directory.\n\n"
"Please remove cache-directory '%2' and restart Monteverdi\n\n"
"Do you want to delete cache-directory '%2' before quitting Monteverdi?"
).arg(nb).arg(application->GetCacheDir().path()),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes
);
if(button==QMessageBox::Yes)
{
if(application->GetCacheDir()==QDir::home())
{
// throw std::runtime_error(
// mvd::ToStdString(
// QCoreApplication::translate(
// "Monteverdi",
// "Tryed to remove home dir."
// )
// )
// );
QMessageBox::critical(
&mainWindow,
QCoreApplication::translate(
PROJECT_NAME,
"Critical error!"
),
QCoreApplication::translate(
PROJECT_NAME,
"Your Monteverdi cache-directory is set to your home directory '%1'. Deletion of cache-directory is aborted to avoid unrecoverable loss of all your account data.\n\nIt is generally a bad idea to set Monteverdi cache-directory to your home directory. Please choose another sub-directory.\n\nApplication will now exit."