Crash when running coomand after form close

Started by jmaeding, November 10, 2014, 06:16:18 PM

Previous topic - Next topic

jmaeding

I show a modal dilaog, then a button on it closes the form, and does a redraw command, like:
(DCL_Form_Close "CT-Civil10" "frm3DAlgPropsT")
(COMMAND "REDRAW")

instant fatal error in 2014 and 2015, but not 2009.
I tried several things like adding (dcl_SetCmdBarFocus) before the command, and sending the coomand via vba sendcommand. Nothing helps, crashes both ways.

Is this a known thing and is there something I must do to avoid the crash?
It does not matter what command I run, I got this error in many places in my programs, so the pattern seems to be the acad version.
Its build 8.0.0.5 for 2015 (64 bit one)... thanks

owenwengerd

#1
This has been discussed frequently here in other threads (e.g. here). You cannot safely call (command) from an event handler of a modal dialog. Just move that code to your main function so that it executes after (dcl-Form-Show) returns, then it will work fine.
Owen Wengerd (Outside The Box) / ManuSoft

jmaeding

That is really odd I never noticed it. Likely because 2009 is ok with it.
I had seen some posts about using command-s, and tried it and it worked.

so now I am wondering how important it is to do what you mention, as its not very convenient.
I would have to set a flag for what button was picked, then have a big conditional after the form show code.

very tempted to stick with command-s, but at least now I know recommended handling.
thanks for your incredibly fast support Owen!!

jmaeding

also, note that I have closed the modal dialog before calling a command.

The example you mentioned was calling command while modal was open.
So its not just closing the dialog, but waiting for return to the open function.
That is unexpected as you would thing you could do anything once the dialog is closed.

owenwengerd

The dialog is not necessarily closed by the time (dcl-Form-Close) returns; it depends on how fast the system processes the Windows messages in the background.
Owen Wengerd (Outside The Box) / ManuSoft

jmaeding

I see. I am still wondering how I just noticed this. I have a major prog that runs in 2009 up to 2015, and use it all the time in 2015. My prog is a composite of lisp and .net, and uses odcl for most dialogs.
I almost cannot think of another issue like this, that would need me to restructure code so much.
I read why 2015 is doing this, and 2009 not, but it seems like just a couple weeks ago it was not doing this in 2014 or 2015. I'll keep reading posts but am so glad this came up now when I have a chance to fix before implementing certain things.