Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 28, 2009, 5:04:38 PM (15 years ago)
Author:
landauf
Message:
  • bugfix in TclBind: Tcl_Init was only called if the constructor of Tcl::interpreter was called with a library path. The initialization is now moved from cpptcl to TclBind.
  • added a new command: TclThreadManager source <file>. This creates a non-interactive tcl-interpreter which executes a file. This allows for example to run the telnet_server.tcl script without a thread compatible tcl library. Warning: experimental state. A script-exit terminates Orxonox.
  • Several small changes in TclThreadManager
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/core/TclBind.cc

    r3354 r3360  
    104104    Tcl::interpreter* TclBind::createTclInterpreter()
    105105    {
    106         Tcl::interpreter* interpreter;
     106        Tcl::interpreter* interpreter = new Tcl::interpreter();
     107        std::string libpath = TclBind::getTclLibraryPath();
     108
     109        try
     110        {
     111            if (libpath != "")
     112                interpreter->eval("set tcl_library \"" + libpath + "\"");
     113
     114            Tcl_Init(interpreter->get());
     115
     116            interpreter->eval("source \"" + TclBind::getInstance().tclDataPath_ + "/init.tcl\"");
     117        }
     118        catch (Tcl::tcl_error const &e)
     119        {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
     120        catch (std::exception const &e)
     121        {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
     122        catch (...)
     123        {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
     124
     125        return interpreter;
     126    }
     127
     128    std::string TclBind::getTclLibraryPath()
     129    {
    107130#ifdef DEPENDENCY_PACKAGE_ENABLE
    108131        if (Core::isDevelopmentRun())
    109             interpreter = new Tcl::interpreter(std::string(ORXONOX_DEP_LIB_PATH) + "/tcl");
     132            return (std::string(ORXONOX_DEP_LIB_PATH) + "/tcl");
    110133        else
    111             interpreter = new Tcl::interpreter(Core::getRootPathString() + "lib/tcl");
     134            return (Core::getRootPathString() + "lib/tcl");
    112135#else
    113         interpreter = new Tcl::interpreter();
     136        return "";
    114137#endif
    115         try
    116         {
    117             interpreter->eval("source \"" + TclBind::getInstance().tclDataPath_ + "/init.tcl\"");
    118         }
    119         catch (Tcl::tcl_error const &e)
    120         {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
    121         catch (std::exception const &e)
    122         {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
    123         catch (...)
    124         {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl;   }
    125 
    126         return interpreter;
    127138    }
    128139
Note: See TracChangeset for help on using the changeset viewer.