OSDN Git Service

* src/tkCanvEdge.c: Work around Windows gcc problem
authormdejong <mdejong>
Tue, 14 Aug 2001 21:26:52 +0000 (21:26 +0000)
committermdejong <mdejong>
Tue, 14 Aug 2001 21:26:52 +0000 (21:26 +0000)
initializing a static member with a dll imported
symbol by assigning the function pointer at runtime.
Static initialization works just fine in VC++ but
fails when compiling with the Windows version of gcc.

libgui/ChangeLog
libgui/src/tkCanvEdge.c

index ca6d716..f55204d 100644 (file)
@@ -1,3 +1,11 @@
+2001-08-12  Mo DeJong  <mdejong@redhat.com>
+
+       * src/tkCanvEdge.c: Work around Windows gcc problem
+       initializing a static member with a dll imported
+       symbol by assigning the function pointer at runtime.
+       Static initialization works just fine in VC++ but
+       fails when compiling with the Windows version of gcc.
+
 2001-08-12  Keith Seitz  <keiths@redhat.com>
 
        Update tkTable to version 2.7:
index aa66702..a7977f0 100644 (file)
@@ -179,8 +179,14 @@ static void                TranslateEdge _ANSI_ARGS_((Tk_Canvas canvas,
 static Tk_CustomOption arrowShapeOption =
 { ParseArrowShape, PrintArrowShape, (ClientData) NULL};
 
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
-    Tk_CanvasTagsPrintProc, (ClientData) NULL};
+/*
+ * The callbacks for tagsOption are initialized in ConfigureEdge()
+ */
+
+static Tk_CustomOption tagsOption =
+{ (Tk_OptionParseProc *) NULL,
+  (Tk_OptionPrintProc *) NULL,
+  (ClientData) NULL};
 
 static Tk_ConfigSpec configSpecs[] = {
   {TK_CONFIG_UID, "-arrow", (char *) NULL, (char *) NULL,
@@ -531,6 +537,17 @@ ConfigureEdge(interp, canvas, itemPtr, argc, argv, flags)
   tkwin = Tk_CanvasTkwin(canvas);
   bgBorder = ((TkCanvas *) canvas)->bgBorder;
 
+  /*
+   * Init callbacks in tagsOption before accessing configSpecs.
+   * This init can't be done statically when using Windows gcc
+   * since these symbols are imported from the Tk dll.
+   */
+
+  if (tagsOption.parseProc == NULL) {
+    tagsOption.parseProc = Tk_CanvasTagsParseProc;
+    tagsOption.printProc = Tk_CanvasTagsPrintProc;
+  }
+
   if (Tk_ConfigureWidget(interp, tkwin,
                         configSpecs, argc, argv,
                         (char *) edgePtr, flags) != TCL_OK) {