VC:MP 0.4 (Beta) > Script Discussion

Server crashes if you call a deleted sprite/textdraw

(1/1)

sseebbyy:
I removed a sprite, then I tried to call it back, but the server stopped.
Shouldn't this be avoided ? To not crash the server if the sprite/textdraw doesn't exist...

heekz.shadow:
The question is: Why would you call a deleted textdraw/sprite ? :)

sseebbyy:

--- Quote from: heekz.shadow on September 13, 2014, 02:26:35 am ---The question is: Why would you call a deleted textdraw/sprite ? :)

--- End quote ---

I just tested it, but there are other cases...
You can forget that you deleted the sprite/textdraw, and just call it.

Anyway, Gudio gave me some answers:

--- Quote ---<Gudio> its because when you do remove or delete
<Gudio> instance in squirrel lang still exists
<Gudio> but not in cpp
<Seby> ah :/
<Gudio> when you call it again after removing, cpp doesnt know what do to
<Seby> why you just don't set it = null; ?
<Gudio> it needs some error handlers or some hack to set variables automatically to null when instance is the same
--- End quote ---

Gudio:
You should set null for variables that you remove to avoid crashes in the future.
Example:

--- Code: ---if ( Timer )
{
Timer.Delete();
Timer = null;
}
--- End code ---

sseebbyy:
Good idea, thanks ! :)
Topic locked.

Navigation

[0] Message Index

Go to full version