Lock up on successive forms

Started by kenkrupa, May 02, 2012, 02:07:55 PM

Previous topic - Next topic

kenkrupa

I believe I have found a nasty bug in 7.0.0.4:

A button on one form closes that form and launches another one (defined in another .odcl file). The second form seems fine, but when I click OK, AutoCAD freezes. The cursor displays as an arrow instead of the normal cross hair. Only thing to do is go to Task Manager to kill it. This has started since downloading 7.0.0.4 - before that it worked fine.

I'm attaching a zip with my files. The two .odcl are the actual files; the two .lsp files are highly lobotomized versions to demonstrate the problem. To test, extract them to a folder on the search path, load FormTest1.lsp, and run FORMTEST command (it will load FormTest2.lsp). Do nothing in the first form except click on the Add Hip/Valley button. At the second form, just click OK. It will be prompting for a point, but it is frozen.

Running ACA 2012, Win7-64.

Fred Tomke

Hi, I cannot believe that it will work: you call kcs_WoodHipValley within running c:hipval_OnClicked event. That means the control isn't given completely back to AutoCAD after closing WB_Dialog when you call the next form. If you press OK on the second form there are still 2 events active in the back when you call (kcs_WoodHipValleyCalc pitch1 pitch2 run1 brg1 brg2 ext1 which beam) and you try to get access to AutoCAD drawing window.

I recommend you to build up your Lisp-File as written in this FAQ. Please have a forum search for interacts with two modal forms. i remember there was a similar case in the past.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Fred is right, you can't safely open a second form while the first is in the process of closing.
Owen Wengerd (Outside The Box) / ManuSoft

kenkrupa

Quote from: owenwengerd on May 03, 2012, 07:22:20 AM
Fred is right, you can't safely open a second form while the first is in the process of closing.

Geez, it did work fine with 6.0.2.3 - but it looks like I'll need to revise my code.

Fred Tomke

Hi, I got it: you will find it here.
Have a good night (I just have to work  :'( ).

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

kenkrupa

I'm still wondering why there was not problem with this using 6.0.2.3, and an associate tells me he has no problem with 7.0.0.2. I don't suppose you guys could find what's different with .4 and put it back the way it was?

Otherwise, I'll delve into that sample code as soon as I can. Thank you.

owenwengerd

Showing a second modal form while the first is still closing has never been safe, and can't be made safe, although it could possibly appear to work in certain scenarios where you have something causing the window messages to be processed in just the right sequence in the background. If it was working in your case, it may have failed in other cases.
Owen Wengerd (Outside The Box) / ManuSoft

kenkrupa

Still don't completely understand why dcl_Form_Close doesn't do it, but I don't need to understand as long as I can make it work <|:-0  {that's me with my dunce hat on}

So, I looked at the code in in the link in Reply #4 (thanks Fred) and got the idea. To sum it up, close the main form with a return value, as in (dcl_Form_Close WB_Dialog 4), and look for that return value in the while loop to launch the child form. Got it. Works now. Thank you.

owenwengerd

It may help to think of (dcl_Form_Close) as simply setting a "close me" flag, but not actually closing anything. When the dialog message loop then gets around to processing window messages again, it encounters the flag and signals the dialog to start it's close process. That's not precisely correct, but it's close. The bottom line is that the dialog is not yet finished closing when (dcl_Form_Close) returns, and it can't possibly finish completely while the event handler is still executing.
Owen Wengerd (Outside The Box) / ManuSoft

kenkrupa

Thanks for the explanation Owen. Now I have it working, and understand better also. So I think I can take off my dunce cap now  ;D