Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Child Window layout causes crash

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Child Window layout causes crash
#9131
Posted by: misi01 2006-12-03 20:49:46 Last edited by: Jeff Glatt 2006-12-13 12:08:34 (Total edited 3 times)
Run the following script. Select the OK button, then select the option FRED from the combo list. I'm getting a crash every time.
/*
GUIBEGIN
WINDOW , 0, 0, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , My Window
	FONT 8, 400, MS Shell Dlg
	PUSH 246, 157, 40, 14, TABSTOP, , ok_button, , OK
DEND
GUIEND
*/
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')

guiaddctl("COMBO 157, 33, 117, 60, DROP|VSCROLL|TABSTOP, , variable_combo")
cobol_vars.1 = 'FRED'
guiaddctltext("variable_combo", "cobol_vars")

again:
DO FOREVER
   guigetmsg()
   CATCH SYNTAX
      CONDITION('M')
      SIGNAL again
   CATCH HALT
   FINALLY
      guidestroywindow()
END
RETURN

wm_select_variable_combo:
   guiremovectl("variable_combo")
   RETURN
Michael
Message2. A (different) crash in RPC
#9158
Posted by: misi01 2006-12-05 20:43:25 Last edited by: Jeff Glatt 2006-12-12 16:15:36 (Total edited 2 times)
Try the following script...
/*
GUIBEGIN
WINDOW , 0, 0, 107, 38, POPUP|CAPTION|SYSMENU|THICK
   FONT 8, 400, MS Shell Dlg
   PUSH 29, 11, 40, 14, TABSTOP, , ok_button, , OK
DEND
GUIEND
*/

LIBRARY rexxgui, rexxinet
guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
  guigetmsg()
  
  /* Did a child object GuiWake me? */
  IF EXISTS('GuiObject') \== 0 THEN DO

     /* DROP the child, thus unloading it and its set of variables */
     IF EXISTS('GuiSignal') == 0 THEN DROP (guiobject)

     /* Get the password that the child script collected. */
     tso_password = password.password_entry

  END
  CATCH SYNTAX
     CONDITION('M')
     SIGNAL again
  CATCH HALT
     guidestroywindow()
END
RETURN

/* Called when the OK button clicked */
wm_click_ok_button:
  /* Create a child window layout to get a password from the user.
   * Use a stem variable name so this script can directly access the
   * child's variables
   */
  createobject("password.rex", "password.")
  RETURN
And the password child script...
/*
GUIBEGIN
WINDOW , 0, 0, 187, 38, POPUP|CAPTION|SYSMENU|THICK, , Password
	FONT 8, 400, MS Shell Dlg
	TEXT 16, 15, 73, 8, GROUP, , password_text
	ENTRY 103, 15, 67, 12, UPPER|PASSWORD|RETURN|BORDER|TABSTOP, CLIENTEDGE, password_entry
	PUSH 3, 28, 22, 9, DEFAULT|HIDE|TABSTOP, , ok_button, , OK
DEND
GUIEND
*/

create:
  guierr = "SYNTAX"
  guiheading = 1
  guicreatewindow('NORMAL', -1)
  RETURN

destroy:
  guidestroywindow()
  RETURN

wm_click_ok_button:
   /* Get the password the user typed */
   guigetctlvalue('password_entry')

   /* Tell main thread to retrieve the password and use it */
   guiwake('POST CLOSE')		

   RETURN
What I'm seeing is a crash on the GuiGetMsg call after the user types in the password and presses RETURN.
Michael
Message3.
#9177
Posted by: Jeff Glatt 2006-12-06 10:12:14 Last edited by: Jeff Glatt 2006-12-12 14:10:25 (Total edited 3 times)
Omg. You have a really odd user interface. You have a control appear in a window, and then when the user operates that very control, it disappears. You really should use a popup window for that sort of thing.

Anyway, the crash is due to deleting a control from within one of its own handlers. That is a very, very bad thing to do. You work at a bank, so let me give you an analogy. A customer decides to pay for some banking fee with a check. Right as he is handing you the check, you're canceling his checking account.

Don't do what you're doing. If you really insist on having controls mysteriously appearing and disappearing in your windows, just show/hide them. Or at least delete the control outside of one of its handlers, for example like this:
/*
GUIBEGIN
WINDOW , 0, 0, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , My Window
    FONT 8, 400, MS Shell Dlg
DEND
GUIEND
*/
LIBRARY rexxgui
guicreatewindow('NORMAL')

guiaddctl("COMBO 157, 33, 117, 60, DROP|VSCROLL|TABSTOP, , variable_combo")
cobol_vars.0 = 1
cobol_vars.1 = 'FRED'
guiaddctltext("variable_combo", "cobol_vars")

again:
DO FOREVER
   guigetmsg()
   IF EXISTS('GuiObject') == 0 THEN DO
      IF EXISTS('GuiSignal') THEN SELECT guisignal
         WHEN 'DELETECOMBO' THEN guiremovectl("variable_combo")
      END
   END
END
RETURN

wm_select_variable_combo:
   guiwake("DELETECOMBO")
   RETURN
Message4.
#9180
Posted by: Jeff Glatt 2006-12-06 11:55:03 Last edited by: Jeff Glatt 2006-12-12 16:21:04 (Total edited 1 time)
In regard to your second problem, this is caused by the following two lines:
   /* DROP the child, thus unloading it and its set of variables */
   IF EXISTS('GuiSignal') == 0 THEN DROP (guiobject)

   /* Get the password that the child script collected. */
   tso_password = password.password_entry

You end up DROP'ing your "PASSWORD." child object, and then you go on to  access the  password_entry variable in that very child script.

Think about it. How can that variable exist if you've dropped the object? The problem is that the "password." variable in your main script still refers to an object, but one that doesn't exist any more. Bang.

If you had gotten the variable first, then things would have gone differently. Make sure you do what you need to do with the object before you DROP it.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-4-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0