Changeset 9161d47 in OpenModelica


Ignore:
Timestamp:
2006-05-15T16:06:49+02:00 (18 years ago)
Author:
x05andfe <x05andfe@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
6aeb3843
Parents:
a46c6e4
Message:

Updated some part of the code to make it work on unix/linux.

  • changed from 'exception' to 'runtime_error'
  • fixed search path for omc

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2384 f25d12d1-65f4-0310-ae8a-bbce733d8d8e

Location:
OMNotebook/OMNotebookQT4
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • OMNotebook/OMNotebookQT4/cellcommands.cpp

    r9c7355a9 r9161d47  
    5959//STD Headers
    6060#include <exception>
     61#include <stdexcept>
    6162
    6263//IAEX Headers
     
    139140      // 2006-01-30 AF, add exception
    140141      string str = string("AddCellCommand(), Exception: \n") + e.what();
    141       throw exception( str.c_str() );
     142      throw runtime_error( str.c_str() );
    142143    }
    143144  }
     
    195196      // 2006-01-30 AF, add exception
    196197      string str = string("CreateNewCommand(), Exception: \n") + e.what();
    197       throw exception( str.c_str() );
     198      throw runtime_error( str.c_str() );
    198199      }
    199200   }
     
    283284      // 2006-01-30 AF, add message box
    284285      string str = string("DeleteCurrentCellsCommand(), Exception: \n") + e.what();
    285     throw exception( str.c_str() );
     286    throw runtime_error( str.c_str() );
    286287      }
    287288   }
     
    329330      // 2006-01-30 AF, add exception
    330331      string str = string("PasteCellsCommand(), Exception: \n") + e.what();
    331       throw exception( str.c_str() );
     332      throw runtime_error( str.c_str() );
    332333    }
    333334  }
     
    459460    {
    460461      // ERROR
    461       throw exception("Unknown cell");
     462      throw runtime_error("Unknown cell");
    462463    }
    463464  }
     
    507508      // 2006-01-30 AF, add exception
    508509      string str = string("DeleteSelectedCellsCommand(), Exception: \n") + e.what();
    509     throw exception( str.c_str() );
     510    throw runtime_error( str.c_str() );
    510511      }
    511512   }
     
    557558      // 2006-01-30 AF, add exception
    558559      string str = string("ChangeStyleOnSelectedCellsCommand(), Exception: \n") + e.what();
    559       throw exception( str.c_str() );
     560      throw runtime_error( str.c_str() );
    560561    }
    561562  }
     
    575576      // 2006-01-30 AF, add exception
    576577      string str = string("ChangeStyleOnCurrentCellCommand(), Exception: \n") + e.what();
    577     throw exception( str.c_str() );
     578    throw runtime_error( str.c_str() );
    578579      }
    579580   }   
     
    603604      // 2006-01-30 AF, add exception
    604605      string str = string("MakeGroupCellCommand(), Exception: \n") + e.what();
    605     throw exception( str.c_str() );
     606    throw runtime_error( str.c_str() );
    606607     
    607608      }
     
    633634          {
    634635            if( !(*c_iter)->hasChilds() )
    635               throw exception( "No children" );
     636              throw runtime_error( "No children" );
    636637
    637638            // get child
     
    697698    {
    698699      string str = string("UngroupCellCommand(), Exception: ") + e.what();
    699       throw exception( str.c_str() );
     700      throw runtime_error( str.c_str() );
    700701    }
    701702  }
     
    759760    {
    760761      string str = string("SplitCellCommand(), Exception: ") + e.what();
    761       throw exception( str.c_str() );
     762      throw runtime_error( str.c_str() );
    762763    }
    763764  }
  • OMNotebook/OMNotebookQT4/cellfactory.cpp

    r9c7355a9 r9161d47  
    113113          text->setStyle( cstyle );
    114114        else
    115           throw exception("No Input style defened, the inputcell may not work correctly, please define a Input style in stylesheet.xml");
     115          throw runtime_error("No Input style defened, the inputcell may not work correctly, please define a Input style in stylesheet.xml");
    116116      }
    117117      catch( exception e )
  • OMNotebook/OMNotebookQT4/cellparserfactory.cpp

    r968d4b96 r9161d47  
    9090      else
    9191      {
    92      throw exception("Can only open files ending with .onb or .nb,\n(can open old OMNotebooks file that ends with .xml)");
     92     throw runtime_error("Can only open files ending with .onb or .nb,\n(can open old OMNotebooks file that ends with .xml)");
    9393      }
    9494   }
  • OMNotebook/OMNotebookQT4/commandcompletion.cpp

    r4938bf2 r9161d47  
    5757//STD Headers
    5858#include <exception>
     59#include <stdexcept>
    5960#include <iostream>
    6061#include <cstdlib>
     
    105106    {
    106107      string tmp = "Could not open file: " + filename.toStdString();
    107       throw exception( tmp.c_str() );
     108      throw runtime_error( tmp.c_str() );
    108109    }
    109110 
     
    114115        filename.toStdString() +
    115116        " Probably some syntax error in the xml file";
    116       throw exception( tmp.c_str() );
     117      throw runtime_error( tmp.c_str() );
    117118    }
    118119    file.close();
     
    388389  {
    389390    if( !item )
    390       throw exception( "ParseCommand... No ITEM set" );
     391      throw runtime_error( "ParseCommand... No ITEM set" );
    391392
    392393    while( !node.isNull() )
  • OMNotebook/OMNotebookQT4/cursorcommands.h

    r4938bf2 r9161d47  
    108108        // 2006-01-30 AF, add exception
    109109        string str = string("CursorMoveUpCommand(), Exception: ") + e.what();
    110         throw exception( str.c_str() );
     110        throw runtime_error( str.c_str() );
    111111      }
    112112    }
     
    162162        // 2006-01-30 AF, add exception
    163163        string str = string("CursorMoveDownCommand(), Exception: ") + e.what();
    164         throw exception( str.c_str() );
     164        throw runtime_error( str.c_str() );
    165165      }
    166166    }
     
    217217        // 2006-01-30 AF, add exception
    218218        string str = string("CursorMoveAfterCommand(), Exception: ") + e.what();
    219         throw exception( str.c_str() );
     219        throw runtime_error( str.c_str() );
    220220      }
    221221    }
  • OMNotebook/OMNotebookQT4/inputcell.cpp

    ra46c6e4 r9161d47  
    15071507  {
    15081508    if(!hasDelegate())
    1509       throw exception("No delegate.");
     1509      throw runtime_error("No delegate.");
    15101510
    15111511    return delegate_;
  • OMNotebook/OMNotebookQT4/notebookcommands.h

    r9c7355a9 r9161d47  
    183183          {
    184184            string msg = "Could not save documet to file: " + filename_.toStdString();
    185             throw exception( msg.c_str() );
     185            throw runtime_error( msg.c_str() );
    186186          }
    187187        }
     
    190190          // 2006-01-30 AF, add exception
    191191          string str = string("SaveDocumentCommand(), Exception: ") + e.what();
    192           throw exception( str.c_str() );
     192          throw runtime_error( str.c_str() );
    193193        }
    194194      }
     
    219219      {
    220220        string msg = string("OpenFileCommand(), Exception:\r\n") + e.what();
    221         throw exception( msg.c_str() );       
     221        throw runtime_error( msg.c_str() );       
    222222      }
    223223    }
     
    252252      {
    253253        string msg = string("OpenOldFileCommand(), Exception:\r\n") + e.what();
    254         throw exception( msg.c_str() );       
     254        throw runtime_error( msg.c_str() );       
    255255      }
    256256    }
     
    292292      {
    293293        string msg = string("PrintDocumentCommand(), Exception:\r\n") + e.what();
    294         throw exception( msg.c_str() );       
     294        throw runtime_error( msg.c_str() );       
    295295      }
    296296    }
     
    323323        // 2006-01-30 AF, add exception
    324324        string str = string("CloseFileCommand(), Exception: ") + e.what();
    325         throw exception( str.c_str() );
     325        throw runtime_error( str.c_str() );
    326326      }
    327327    }
     
    353353        // 2006-01-30 AF, add exception
    354354        string str = string("NewFileCommand(), Exception: ") + e.what();
    355         throw exception( str.c_str() );
     355        throw runtime_error( str.c_str() );
    356356      }
    357357    }
     
    385385        {
    386386          string msg = "Could not export text to file: " + filename_.toStdString();
    387           throw exception( msg.c_str() );
     387          throw runtime_error( msg.c_str() );
    388388        }
    389389
     
    394394        // 2006-01-30 AF, add exception
    395395        string str = string("ExportToPureText(), Exception: ") + e.what();
    396         throw exception( str.c_str() );
     396        throw runtime_error( str.c_str() );
    397397      }     
    398398    }
     
    435435      {
    436436        string str = string("EvalSelectedCells(), Exception: ") + e.what();
    437         throw exception( str.c_str() );
     437        throw runtime_error( str.c_str() );
    438438      }     
    439439    }
     
    487487      {
    488488        string str = string("UpdateChapterCounters(), Exception: ") + e.what();
    489         throw exception( str.c_str() );
     489        throw runtime_error( str.c_str() );
    490490      }     
    491491    }
  • OMNotebook/OMNotebookQT4/notebooksocket.cpp

    r9c7355a9 r9161d47  
    8484
    8585    // something is wrong, throw exception
    86     throw exception( "Unable to connect OR start server" );
     86    throw runtime_error( "Unable to connect OR start server" );
    8787  }
    8888
     
    104104        if( socket_->state() == QAbstractSocket::ConnectedState )
    105105          if( !socket_->waitForDisconnected( 5000 ))
    106             throw exception( "Unable to disconnect socket from host" );
     106            throw runtime_error( "Unable to disconnect socket from host" );
    107107      }
    108108
     
    153153    }
    154154
    155     throw exception( "Didn't found correct server" );
     155    throw runtime_error( "Didn't found correct server" );
    156156  }
    157157
  • OMNotebook/OMNotebookQT4/omc_communicator.cpp

    r4938bf2 r9161d47  
    237237    // 2006-02-02 AF, Added throw exception
    238238    string msg = string("OMC-ERROR in function call: ") + fnCall.toStdString();
    239     throw exception( msg.c_str() );
     239    throw runtime_error( msg.c_str() );
    240240  }
    241241
     
    258258      {
    259259        // 2006-02-02 AF, Added throw exception
    260         throw exception("OMC is not responding");
     260        throw runtime_error("OMC is not responding");
    261261      }
    262262      else
  • OMNotebook/OMNotebookQT4/omcinteractiveenvironment.cpp

    r9c7355a9 r9161d47  
    213213    {
    214214      // 2006-02-28 AF, use environment varable to find omc.exe
    215       string drmodelica( getenv( "OPENMODELICAHOME" ) );
    216       if( drmodelica.empty() )
    217         throw std::exception( "Could not find environment variable OPENMODELICAHOME" );
     215      string OMCPath( getenv( "OPENMODELICAHOME" ) );
     216      if( OMCPath.empty() )
     217        throw std::runtime_error( "Could not find environment variable OPENMODELICAHOME" );
    218218
    219219      // location of omc in openmodelica folder
    220220      QDir dir;
    221       if( dir.exists( QString(drmodelica.c_str()) + "\\bin\\omc.exe" ) )
    222         drmodelica += "\\bin\\";
    223       else if( dir.exists( QString(drmodelica.c_str()) + "\\omc.exe" ) )
    224         drmodelica;
     221#ifdef WIN32
     222      if( dir.exists( QString(OMCPath.c_str()) + "\\bin\\omc.exe" ) )
     223        OMCPath += "\\bin\\";
     224      else if( dir.exists( QString(OMCPath.c_str()) + "\\omc.exe" ) )
     225        OMCPath;
    225226      else if( dir.exists( "omc.exe" ))
    226         drmodelica = "";
     227        OMCPath = "";
    227228      else
    228229      {
    229230        string msg = "Unable to find OMC, searched in:\n" +
    230           drmodelica + "\\bin\\\n" +
    231           drmodelica + "\n" +
     231          OMCPath + "\\bin\\\n" +
     232          OMCPath + "\n" +
    232233          dir.absolutePath().toStdString();
    233234
    234         throw std::exception( msg.c_str() );
     235        throw std::runtime_error( msg.c_str() );
    235236      }
     237#else /* unix */
     238      if( dir.exists( QString(OMCPath.c_str()) + "/bin/omc" ) )
     239        OMCPath += "/bin/";
     240      else if( dir.exists( QString(OMCPath.c_str()) + "/omc" ) )
     241        OMCPath;
     242      else if( dir.exists( "omc.exe" ))
     243        OMCPath = "";
     244      else
     245      {
     246        string msg = "Unable to find OMC, searched in:\n" +
     247          OMCPath + "/bin/\n" +
     248          OMCPath + "\n" +
     249          dir.absolutePath().toStdString();
     250
     251        throw std::runtime_error( msg.c_str() );
     252      }
     253#endif
    236254     
    237255
     
    239257      QString omc;
    240258      #ifdef WIN32
    241         omc = QString( drmodelica.c_str() ) + "omc.exe";
     259        omc = QString( OMCPath.c_str() ) + "omc.exe";
    242260      #else
    243         omc = QString( drmodelica.c_str() ) + "omc";
     261        omc = QString( OMCPath.c_str() ) + "omc";
    244262      #endif
    245263     
     
    254272
    255273      // give time to start up..
    256       SleeperThread::msleep( 500 );
    257 
    258       if( QProcess::Running == omcProcess->state() )
     274      if( omcProcess->waitForStarted(2000) )
    259275        flag = true;
    260276      else
     
    282298
    283299      if( !flag )
    284         throw std::exception("Was unable to start OMC");
     300        throw std::runtime_error("Was unable to start OMC");
    285301
    286302        */
  • OMNotebook/OMNotebookQT4/openmodelicahighlighter.cpp

    ra46c6e4 r9161d47  
    6262//STD Headers
    6363#include <exception>
     64#include <stdexcept>
    6465#include <iostream>
    6566
     
    344345    {
    345346      string tmp = "Could not open " + filename_.toStdString();
    346       throw exception( tmp.c_str() );
     347      throw runtime_error( tmp.c_str() );
    347348    }
    348349
     
    352353
    353354      string tmp = "Could not understand content of " +  filename_.toStdString();
    354       throw exception( tmp.c_str() );
     355      throw runtime_error( tmp.c_str() );
    355356    }
    356357    file.close();
  • OMNotebook/OMNotebookQT4/stylesheet.cpp

    r673590f r9161d47  
    6161//STD Headers
    6262#include <exception>
     63#include <stdexcept>
    6364#include <iostream>
    6465#include <cstdlib>
     
    103104      // 2005-10-03 AF, thorw exception insted of exit
    104105      string tmp = "Could not open file: " + filename.toStdString();
    105       throw exception( tmp.c_str() );
     106      throw runtime_error( tmp.c_str() );
    106107    }
    107108
     
    115116        filename.toStdString() +
    116117        " Probably some syntax error in the xml file";
    117       throw exception( tmp.c_str() );
     118      throw runtime_error( tmp.c_str() );
    118119    }
    119120    file.close();
     
    278279  {
    279280    if( !item )
    280       throw exception( "STYLESHEET TRAVERSE... No ITEM SET!!" );
     281      throw runtime_error( "STYLESHEET TRAVERSE... No ITEM SET!!" );
    281282
    282283    while( !node.isNull() )
  • OMNotebook/OMNotebookQT4/textcursorcommands.cpp

    r673590f r9161d47  
    5353 * \brief Describes different textcursor commands
    5454 */
    55 
    5655
    5756//QT Headers
     
    548547      {
    549548        string str = string("Could not open image: ") + filepath_.toStdString().c_str();
    550         throw exception( str.c_str() );
     549        throw runtime_error( str.c_str() );
    551550      }
    552551    }
  • OMNotebook/OMNotebookQT4/updatelinkvisitor.cpp

    r4938bf2 r9161d47  
    5353//STD Headers
    5454#include <exception>
     55#include <stdexcept>
    5556
    5657//QT Headers
     
    8889    {
    8990      string msg = "UpdateLink, old or new dir don't exists.";
    90       throw exception( msg.c_str() );
     91      throw runtime_error( msg.c_str() );
    9192    }
    9293  }
     
    145146          // this should never happen!
    146147          string msg = "Error, found no end of linkpath";
    147                     throw exception( msg.c_str() );
     148                    throw runtime_error( msg.c_str() );
    148149          break;
    149150        }
  • OMNotebook/OMNotebookQT4/xmlparser.cpp

    r673590f r9161d47  
    135135    {
    136136      string msg = "Could not open " + filename_.toStdString();
    137       throw exception( msg.c_str() );
     137      throw runtime_error( msg.c_str() );
    138138    }
    139139   
     
    142142      file.close();
    143143      string msg = "Could not understand content of " + filename_.toStdString();
    144       throw exception( msg.c_str() );
     144      throw runtime_error( msg.c_str() );
    145145    }
    146146    file.close();
     
    183183      string msg = "Wrong root node (" + root.toElement().tagName().toStdString() +
    184184        ") in file " + filename_.toStdString();
    185       throw exception( msg.c_str() );
     185      throw runtime_error( msg.c_str() );
    186186    }
    187187
     
    213213    {
    214214      string msg = "File " + filename_.toStdString() + " is empty";
    215       throw exception( msg.c_str() );
     215      throw runtime_error( msg.c_str() );
    216216    }
    217217
     
    237237      string msg = "Wrong root node (" + root.toElement().tagName().toStdString() +
    238238        ") in file " + filename_.toStdString() + " (Old File)";
    239       throw exception( msg.c_str() );
     239      throw runtime_error( msg.c_str() );
    240240    }
    241241
     
    292292          {
    293293            string msg = "Unknow tag name: " + element.tagName().toStdString() + ", in file " + filename_.toStdString();
    294             throw exception( msg.c_str() );
     294            throw runtime_error( msg.c_str() );
    295295          }
    296296        }
     
    332332      groupcell->setClosed( false );
    333333    else
    334       throw exception( "Unknown closed value in group cell" );
     334      throw runtime_error( "Unknown closed value in group cell" );
    335335
    336336    parent->addChild( groupcell );
     
    380380        {
    381381          string msg = "Unknown tagname " + e.tagName().toStdString() + ", in text cell";
    382           throw exception( msg.c_str() );
     382          throw runtime_error( msg.c_str() );
    383383        }
    384384      }
     
    450450        {
    451451          string msg = "Unknown tagname " + e.tagName().toStdString() + ", in input cell";
    452           throw exception( msg.c_str() );
     452          throw runtime_error( msg.c_str() );
    453453        }
    454454      }
     
    468468      inputcell->setClosed( false );
    469469    else
    470       throw exception( "Unknown closed value in inputcell" );
     470      throw runtime_error( "Unknown closed value in inputcell" );
    471471
    472472    parent->addChild( inputcell );
     
    493493    QString imagename = element.attribute( XML_NAME, "" );
    494494    if( imagename.isEmpty() || imagename.isNull() )
    495       throw exception( "No name in image tag" );
     495      throw runtime_error( "No name in image tag" );
    496496
    497497    // Get saved image data
     
    527527      {
    528528        string msg = "Unknown typeid of parent cell";
    529         throw exception( msg.c_str() );
     529        throw runtime_error( msg.c_str() );
    530530      }
    531531    }
     
    533533    {
    534534      string msg = "Error creating image: <"+ imagename.toStdString() +">";
    535       throw exception( msg.c_str() );
     535      throw runtime_error( msg.c_str() );
    536536    }
    537537  }
     
    587587        {
    588588          string msg = "Unknown tag: <"+ e.tagName().toStdString() +">";
    589           throw exception( msg.c_str() );
     589          throw runtime_error( msg.c_str() );
    590590        }
    591591      }
Note: See TracChangeset for help on using the changeset viewer.