Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] (PR#6452) Xaw client segmentation fault on international e
Home

[Freeciv-Dev] (PR#6452) Xaw client segmentation fault on international e

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: hzhr@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#6452) Xaw client segmentation fault on international environment
From: "Guest" <rt-guest@xxxxxxxxxxxxxx>
Date: Thu, 9 Oct 2003 05:43:44 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Hi, following the file doc/INSTALL.Cygwin, I get freeciv-1.14.1-beta1 
successfully
compiled and run on Cygwin with Xaw client, thank you all!

I'm a Chinese user, so I add a line to Xt resources file Freeciv like:

Freeciv*international:   True

to get international environment, then the Xaw client can display 
Chinese characters
correctly. But when I click the "Connect" button on the "Connect to 
Freeciv Server"
dialog, then Xaw client got a segmentation fault.

.......
Program received signal SIGSEGV, Segmentation fault.
0x006d8405 in XTextWidth ()
(gdb) bt
#0  0x006d8405 in XTextWidth ()
#1  0x004319e6 in real_append_output_window ()
#2  0x00413e18 in handle_chat_msg ()
#3  0x00404157 in handle_packet_input ()
#4  0x0040814c in input_from_server ()
#5  0x004ecae3 in DoOtherSources ()
#6  0x004ecfb8 in XtAppNextEvent ()
#7  0x004f48cc in XtAppMainLoop ()
#8  0x004229a4 in ui_main ()
#9  0x004039ce in main ()
(gdb) 
......


I don't know whether others systems(Linux, etc) have this problem too, 
but on cygwin,
it was caused by an un-initialized variable in function 
real_append_output_window()
in file client/gui-xaw/chatline.c:

85  if (!m_width) {
86    XFontStruct *out_font;   ----> not initialized
87    XtVaGetValues(outputwindow_text, XtNfont, &out_font, NULL);
88    if (out_font)
89      m_width=XTextWidth(out_font, "M", 1);
90    else
91      m_width=10;
92  }

I don't knows what's the real reason, but seems that when set 
Freeciv*international to True,
libXaw uses XFontSet instead of XFontStruct for all widgets, so 
   XtVaGetValues(outputwindow_text, XtNfont, &out_font, NULL);
can't initialize the variable out_font, and XTextWidth will fail.

I'm not family with X programming, so here is a little patch to solve 
the problem --
just initialize the variable out_font:

--- client/gui-xaw/chatline.c.orig      2003-10-09 18:46:08.000000000 
+0800
+++ client/gui-xaw/chatline.c   2003-10-09 18:46:40.000000000 +0800
@@ -83,7 +83,7 @@ void real_append_output_window(const cha
   char *newout, *rmcr, *astring = mystrdup(input_string);
 
   if (!m_width) {
-    XFontStruct *out_font;
+    XFontStruct *out_font = NULL;
     XtVaGetValues(outputwindow_text, XtNfont, &out_font, NULL);
     if (out_font)
       m_width=XTextWidth(out_font, "M", 1);


I think the better way is to check the international environment, and 
get out_font
from XFontSet, but how to do it?

PS: When I set Freeciv*international to True, nearly all text on 
widgets are internationalized,
but the text in the game maps. After a glancing of the source code, I 
found in file graphics.c and mapview.c,
it use single XFontStruct but not XFontSet to draw strings, so this 
causes the problem.
So, can anybody try to fix it?

Thank you all!



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6452) Xaw client segmentation fault on international environment, Guest <=