PDA

View Full Version : ClearScene() crashes LW



Paul_Newman
11-15-2003, 05:22 PM
I have a generic LScript running in LW7.5(a)

The script loads a LW scene file, modifies some bones, textures and cameras and saves it. But when ClearScene() is called prior to loading another scene file, LW crashes!

Loading the same scene manually and clearing works just fine. I've tested this thing in so many ways but it keeps on crashing.

Before the call to ClearScene(), I first set all the object instance variables to nil so that they no longer reference data that's about to be cleared.

The strange thing is that amongst about 50 tests, there would be one where LW does not crash and the script then works as designed. This made me wonder . . . but I'm really to frizzled out to wonder some more. 01h22 and my eyes are burning.

Can anyone help me out?

Thanks,

Paul

faulknermano
11-15-2003, 09:24 PM
cannot be sure, but i think lw tries to clear the script from memory when you run ClearScene(). try using a master class lscript. be sure to add a flags() function to return the LAYOUT constant (p.166 of the USER GUIDE - not the REFERENCE):



flags
{
return(LAYOUT);
}



hopefully that works.

Paul_Newman
11-16-2003, 02:01 AM
"lw tries to clear the script from memory when you run ClearScene()"

That's something I haven't thought of before. The thing is, this Generic script is quite a large system (7500 lines) which was developed to override the LW interface by way of the Generic script features. Going to Master script will mean changing A LOT and loosing that feature.

Another thing is that early on in development, this loading and clearing by way of Generic script worked fine. The script was happy, LW was happy, I was happy. Now, some time down the development line, I haven't been testing the basics of loading and clearing scenes but focusing on developing and testing all the piles other features. Now I come back to find that loading and clearing crashes LW. This leads me to believe that somewhere I've written code that's not behaving itself properly. But where to look in such a large script? So I was hoping someone could shed some light on what makes a script behave badly in such a situation.

My thoughts are that somehow object references to the data in each newly loaded scene (I have a UDF which scans each new scene and creates instances of everything I need to manipulate) get messed up when I suddenly clear then scene so that the instances now no longer have data to which they were supposed to be connected. To solve this possibility, I wrote a UDF which first made each global variable "nil" thereby breaking the link between the variables and the objects (cameras, bones, lights, textures, images, etc.) in the scene. But still the crashes persist. Perhaps my reasoning is correct but I'm overlooking some data links which still exist.

I'll write a new generic script and see if I can reconstruct the problem. Hopefully that will shed some light . . .

Thanks for offering your help.

Paul

Paul_Newman
11-16-2003, 04:31 AM
The code for my test script is below. It loads scene 1 OK. Then loads scene 2 OK. Then trying to load scene 1 again causes LW to crash. The script is simple, with no object agents set up or anything - just load and clear (as I understand it, when LW loads a new scene it automatically first does ClearScene).

If I load a scene and explicitly click on the ClearScene button, LW also crashes.

This is strange considering the LScript User Manual documents the loadscene function in its discussion of Generic Scripts.

OK wait. I've just tested the script with 2 basic scenes. Just an object in each, no bones, nothing heavy. . . and IT WORKS!! Load, Clear, Load, Clear.

Now the questions is : What is in the scenes which I'm trying to manipulate with my script that is so disagreeable with LW?

Thanks for listening to my problems,

Paul

@version 2.5
@warnings
@name softBOX_Clear
@script generic

generic
{
reqbegin("Load / Clear Test");

c0 = ctlbutton("Load Scene 1",100,"Load_scene_1");
c1 = ctlbutton("Load Scene 2",100,"Load_scene_2");
c2 = ctlbutton("Clear Scene",100,"Clear_Scene");
c3 = ctlbutton("Refresh Scene",100,"Refresh_Scene");

return if !reqpost();

reqend();
}

Load_scene_1
{
LoadScene("C:\\jet.lws");
}

Load_scene_2
{
LoadScene("C:\\jumbo_jet.lws");
}

Clear_Scene
{
ClearScene();
}

Refresh_Scene
{
RefreshNow();
}

faulknermano
11-16-2003, 07:27 AM
i wouldnt be able to test the script at any rate.

however, it is not surprising that lw will crash on clearing. i think it is a memory management issue and it is not necessarily lscript's issue. however, lscript adds another layer of possible problems, because it allocates its own memory for stuff (i think) in addition to lw's own. this is just my impression; i do not know for a fact.

if the question of ClearScene() working on some cases, and some cases not then i dont know. i've had lw crash on its own (without using any lscript) when i tried the clear the scene "manually."

regarding "porting" the generic to the master: i did that for a couple of lscripts before. the biggest of which was about 2000 lines. it's actually quite simple: replace generic() with options() and leave the process() and create() funcs blank (or place in them whatever you like). in most cases nothing should go wrong.

i would like to be sure, however, if doing it the master-class way will resolve the issue. maybe you'd like to test it first if you decide to do it.

Paul_Newman
11-16-2003, 09:04 AM
Thanks for the info on converting from Generic to Master. That may come in handy.

Right now I'm doing several tests to see if there's any offending items inside the scene that LW's not happy with.

[much later]

After all these tests, I discovered that executing RefreshNow seems to be the offender, causing any subsequent ClearScene to crash LW. Even after repeatedly loading and clearing my original problem scenes with success 20 to 30 times consecutively, as soon as I issue the RefreshNow command and then perform a ClearScene fuction thereafter, LW crashes.

Since my script makes HEAVY use of RefreshNow to allow the user to see the effects of the script changes in the scene, I'll have to change the design of the script to only allow the user the loading and editing of one scene at a time, closing LW down after each project. Call it primitive memory management.

I hope these tests I did tell the story like it is, because I'm getting really tired of dealing with issues that shouldn't be issues in the first place.

Thanks again for listening,

Paul