Revision: 42245
          http://brlcad.svn.sourceforge.net/brlcad/?rev=42245&view=rev
Author:   starseeker
Date:     2011-01-13 16:22:28 +0000 (Thu, 13 Jan 2011)

Log Message:
-----------
OK, revert to the previous two pass code, but use bu_argv0_full_path instead of 
bu_getprogname to prevent the build dir mged from getting the path info from 
the installed mged.

Modified Paths:
--------------
    brlcad/branches/cmake/src/mged/setup.c

Modified: brlcad/branches/cmake/src/mged/setup.c
===================================================================
--- brlcad/branches/cmake/src/mged/setup.c      2011-01-13 15:26:10 UTC (rev 
42244)
+++ brlcad/branches/cmake/src/mged/setup.c      2011-01-13 16:22:28 UTC (rev 
42245)
@@ -483,7 +483,7 @@
     int init_tcl = 1;
     int init_itcl = 1;
     struct bu_vls str;
-    const char *name = bu_getprogname();
+    const char *name = bu_argv0_full_path();
 
     /* locate our run-time binary (must be called before Tcl_CreateInterp()) */
     if (name) {
@@ -498,19 +498,46 @@
     /* Create the interpreter */
     *interpreter = Tcl_CreateInterp();
 
-    /* Locate the BRL-CAD-specific Tcl scripts, set the auto_path */
-    tclcad_auto_path(*interpreter);
-    
-    /* We've got the paths set, now initialize the interperter */ 
-    if (Tcl_Init(*interpreter) != TCL_OK) {
+    /* a two-pass init loop.  the first pass just tries default init
+     * routines while the second calls tclcad_auto_path() to help it
+     * find other, potentially uninstalled, resources.
+     */
+    while (1) {
+
+       /* not called first time through, give Tcl_Init() a chance */
+       if (try_auto_path) {
+           /* Locate the BRL-CAD-specific Tcl scripts, set the auto_path */
+           tclcad_auto_path(*interpreter);
+       }
+
+       /* Initialize Tcl */
+       Tcl_ResetResult(*interpreter);
+       if (init_tcl && Tcl_Init(*interpreter) == TCL_ERROR) {
+           if (!try_auto_path) {
+               try_auto_path=1;
+               continue;
+           }
            bu_log("Tcl_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter));
-           Tcl_ResetResult(*interpreter);
-    }
+           break;
+       }
+       init_tcl=0;
 
-    /* Initialize [incr Tcl] */
-    if (Tcl_Eval(*interpreter, "package require Itcl") != TCL_OK) {
+       /* Initialize [incr Tcl] */
+       if (Tcl_Eval(*interpreter, "package require Itcl") != TCL_OK) {
            bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(*interpreter));
-           Tcl_ResetResult(*interpreter);
+           break;
+       }
+
+       /* don't actually want to loop forever */
+       break;
+
+    } /* end iteration over Init() routines that need auto_path */
+    Tcl_ResetResult(*interpreter);
+
+    /* if we haven't loaded by now, load auto_path so we find our tclscripts */
+    if (!try_auto_path) {
+       /* Locate the BRL-CAD-specific Tcl scripts */
+       tclcad_auto_path(*interpreter);
     }
 
     /*XXX FIXME: Should not be importing Itcl into the global namespace */


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to