set up a tcl event handler if xschem is run without other event loops (no tk event loop, -x option, no tclreadline event loop, -r option) so xschem will respond to tcp connections

This commit is contained in:
Stefan Frederik 2022-10-25 01:00:51 +02:00
parent 4c43e77818
commit 2c9151ea92
2 changed files with 11 additions and 3 deletions

View File

@ -101,9 +101,8 @@ int main(int argc, char **argv)
}
if(detach) fclose(stdin);
if(detach && has_x) {
fclose(stdin);
Tcl_FindExecutable(argv[0]); /* tcl stores executable name for its internal usage */
interp = Tcl_CreateInterp(); /* create the tcl interpreter */
Tcl_AppInit(interp); /* execute our init function */

View File

@ -1883,6 +1883,11 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h)
} /* end if(has_x) */
}
static void tclmainloop(void)
{
while(1) Tcl_DoOneEvent(TCL_ALL_EVENTS);
}
int Tcl_AppInit(Tcl_Interp *inter)
{
char name[PATH_MAX]; /* overflow safe 20161122 */
@ -2564,7 +2569,11 @@ int Tcl_AppInit(Tcl_Interp *inter)
"::tclreadline::Loop }"
);
}
/* set up a tcl event handler to serve events (tcp connections) if no other
* event queue is running (no tk event queue, no tclreadline event loop)
* otherwise you have to manually call a vwait or update command to let
* tcp callbacks respond */
if(!has_x) Tcl_SetMainLoop(tclmainloop);
dbg(1, "Tcl_AppInit(): returning TCL_OK\n");
return TCL_OK;
}