Skip to content

Commit

Permalink
- Catch the std::runtime_error.
Browse files Browse the repository at this point in the history
- Better checking for translations file.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11632 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 2, 2012
1 parent e1e8462 commit a62b230
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions OMEdit/OMEditGUI/main.cpp
Expand Up @@ -61,19 +61,28 @@ int main(int argc, char *argv[])
splashScreen.setMessage();
splashScreen.show();

//*a.severin/ add localozation
const char *omhome = getenv("OPENMODELICAHOME");
#ifdef WIN32
if (!omhome) throw std::runtime_error(GUIMessages::getMessage(GUIMessages::OPEN_MODELICA_HOME_NOT_FOUND).toStdString());
#else /* unix */
omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
QString dir = omhome + QString("/share/omedit/nls");
QString locale = QString("OMEdit_") + QLocale::system().name(); //+ QString(".qm");
QTranslator translator;
translator.load(locale, dir);
a.installTranslator(&translator);
//a.severin*/
try
{
//*a.severin/ add localization
const char *omhome = getenv("OPENMODELICAHOME");
#ifdef WIN32
if (!omhome) throw std::runtime_error(GUIMessages::getMessage(GUIMessages::OPEN_MODELICA_HOME_NOT_FOUND).toStdString());
#else /* unix */
omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
QString dir = omhome + QString("/share/omedit/nls");
QString locale = QString("OMEdit_") + QLocale::system().name();
QTranslator translator;
if (!translator.load(locale, dir))
throw std::runtime_error(QString(GUIMessages::getMessage(GUIMessages::UNABLE_TO_LOAD_FILE).arg(locale)).toStdString());
a.installTranslator(&translator);
//a.severin*/
}
catch(std::exception &e)
{
QString msg = e.what();
QMessageBox::critical(0, Helper::applicationName + " - Error", msg.append("\n\n").append("Unable to load translations file."), "OK");
}

MainWindow mainwindow(&splashScreen);
if (mainwindow.mExitApplication) { // if there is some issue in running the application.
Expand Down

0 comments on commit a62b230

Please sign in to comment.