1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
From: Ole Streicher <olebole@debian.org>
Date: Mon, 5 Aug 2024 22:46:35 +0200
Subject: [tksao] Make internalError() working locally
The function uses a Tcl_Interp *global_interp which was never set. A
similar function is also defined in tclfitsy, as this may be loaded as
a separate package.
---
tclfitsy/tclfitsy.C | 14 ++++++++++++--
tksao/saotk.C | 11 ++++++++---
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/tclfitsy/tclfitsy.C b/tclfitsy/tclfitsy.C
index f9c6630..e903d50 100644
--- a/tclfitsy/tclfitsy.C
+++ b/tclfitsy/tclfitsy.C
@@ -28,6 +28,15 @@ extern "C" {
TclFITSY* fitsy=NULL;
+static Tcl_Interp* tclfitsy_interp = NULL;
+
+void internalError(const char* msg) {
+ if (tclfitsy_interp != NULL) {
+ Tcl_SetVar2(tclfitsy_interp, "ds9", "msg", msg, TCL_GLOBAL_ONLY);
+ Tcl_SetVar2(tclfitsy_interp, "ds9", "msg,level", "error", TCL_GLOBAL_ONLY);
+ }
+}
+
int Tclfitsy_Init(Tcl_Interp* interp) {
if (Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0) == NULL)
@@ -41,9 +50,10 @@ int Tclfitsy_Init(Tcl_Interp* interp) {
fitsy = new TclFITSY(interp);
- if (fitsy)
+ if (fitsy) {
+ tclfitsy_interp = interp;
return TCL_OK;
- else
+ } else
return TCL_ERROR;
}
diff --git a/tksao/saotk.C b/tksao/saotk.C
index 4a53d65..aa59bbb 100644
--- a/tksao/saotk.C
+++ b/tksao/saotk.C
@@ -54,11 +54,14 @@ extern "C" {
const char* argv[]);
}
+static Tcl_Interp* saotk_interp = NULL;
+
void internalError(const char* msg)
{
- extern Tcl_Interp *global_interp;
- Tcl_SetVar2(global_interp, "ds9", "msg", msg, TCL_GLOBAL_ONLY);
- Tcl_SetVar2(global_interp, "ds9", "msg,level", "error", TCL_GLOBAL_ONLY);
+ if (saotk_interp != NULL) {
+ Tcl_SetVar2(saotk_interp, "ds9", "msg", msg, TCL_GLOBAL_ONLY);
+ Tcl_SetVar2(saotk_interp, "ds9", "msg,level", "error", TCL_GLOBAL_ONLY);
+ }
}
int Tksao_Init(Tcl_Interp* interp) {
@@ -151,6 +154,8 @@ int Tksao_Init(Tcl_Interp* interp) {
if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK)
return TCL_ERROR;
+ saotk_interp = interp;
+
return TCL_OK;
}
|