Possible BugFixing on Save against Engine.

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Possible BugFixing on Save against Engine.

Postby Anthony » 27 May 2009, 08:37

Hello,
Still in development of TwilightChess mod, I think I found a bug when you save a game against the computer.
With my version it doesn't work. The solution is very simple. In winboard.c, the function:

Code: Select all
OpenFileDialog (HWND hwnd, char * write, defName char *, char * defExt, nameFilt char *, char * dlgTitle, UINT * number, fileTitle char [MSG_SIZ], char fileName [MSG_SIZ])


Just initialize hwnd, buf1.
Code: Select all
/* Begin TwilightChess  Change */
   hwnd = NULL;
   *buf1 = 0;
/* End */


I hope its will help you. And if this problem is just in my version please forgive me.
Best regards,
Anthony.
Anthony
 
Posts: 5
Joined: 05 Apr 2009, 10:08
Location: Grenoble, France

Re: Possible BugFixing on Save against Engine.

Postby H.G.Muller » 27 May 2009, 10:55

Hmm, this is a bit strange. The only place I could find where buf1 is used, is in the following code:
Code: Select all
  if (fileName == NULL) fileName = buf1;
  if (defName == NULL) {
    strcpy(fileName, "*.");
    strcat(fileName, defExt);
  } else {
    strcpy(fileName, defName);
  }

No matter what defName is, the contents of buf1[] is then always overwritten by a strcpy. This should not be dependent on what was in buf1 before.

The only usage of hwnd I could find is that it is passed to a routine that creates an error popup when the file could not be opened. Quite possible that setting hwnd=NULL supresses this error popup, because NULL might be an illegal value for the API that is supposed to create it. That does not mean that the real problem (of not being abl to open the file) was solved...
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Possible BugFixing on Save against Engine.

Postby Anthony » 27 May 2009, 13:43

It's right that this bug is curious, but on my version build with cygwin (on a Windows Vista Business Edition) if I don't put this two lines, the save dialog may not open. And this error message appears : "Internal error in file dialog box ...".
I think is just an error on my version.
Best regards,
Anthony.
Anthony
 
Posts: 5
Joined: 05 Apr 2009, 10:08
Location: Grenoble, France

Re: Possible BugFixing on Save against Engine.

Postby Eric Mullins » 27 May 2009, 20:08

buf1 is just a buffer used by GetSaveFileName() in the event that the argument 'fileName' was passed as NULL-- essentially saying, "I'm not supplying a buffer, use your own internal one". According to msdn, the OPENFILENAME structure's lpstrFile member serves a dual purpose. It provides the initial file to display in the dialog's edit control, and it contains the user's selected filename upon return. So yes, it should be set to an empty string if it's being used-- otherwise, the dialog would try to initialize the edit control with garbage that was on the stack. Except that as HGM pointed out, the buffer is always initialized with a strcpy(). So, if the buffer is causing problems, then it looks like the caller is sending a bad value for defName and/or defExt-- the value(s) used to initialize the buffer.

For hwnd, I don't see any need to set this to NULL. It's a passed argument that's supposed to be the parent. If setting this to NULL helps, then I would say the caller is sending an invalid and non-null value to OpenFileDialog().
Eric Mullins
 
Posts: 47
Joined: 28 Aug 2008, 04:54
Location: Albuquerque, NM


Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 28 guests