Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
108 stars 83 forks source link

Deleted actions/conditions tied to variables can reappear under certain conditions #2478

Open Wackytoaster opened 5 years ago

Wackytoaster commented 5 years ago

Problem description

Under certain conditions deleted actions can reappear. I think this happens only with variables but maybe I´m wrong here. The type of variable doesn´t actually matter.

EDIT: I thought that this might also apply to conditions and after testing it, yes it does. The steps to reproduce are basically the same, except with a condition.

ahh

Attach a .c3p

variablebug.c3p.zip

Steps to reproduce

  1. Delete the global boolean variable (hit ok)
  2. Create a global variable with the same name (should be the standard name) but make it a string or number variable
  3. Add a new action to the every tick event "set variable to 0" or similar
  4. Drag & Drop this action above the "go to layout" action

Observed result

The deleted "set boolean to true" reappears

Expected result

Not have it reappear

First affected release

Checked back to r120, but this might have been in longer

Affected browsers/platforms

System details

View details Platform information Browser: Chrome Browser version: 71.0.3578.98 Browser engine: Blink Browser architecture: 64-bit Context: webapp Operating system: Windows Operating system version: 10 Operating system architecture: 64-bit Device type: desktop Device pixel ratio: 1 Logical CPU cores: 8 Approx. device memory: 8 GB User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 C3 release: r131 (stable) Language setting: en-US Local storage Storage quota (approx): 31 gb Storage usage (approx): 337 mb (1.1%) Persistant storage: Yes Browser support notes This list contains missing features that are not required, but could improve performance or user experience if supported. Nothing is missing. Everything is OK! WebGL information Version string: WebGL 2.0 (OpenGL ES 3.0 Chromium) Numeric version: 2 Supports NPOT textures: yes Supports GPU profiling: yes Supports highp precision: yes Vendor: Google Inc. Renderer: ANGLE (Intel(R) HD Graphics 530 Direct3D11 vs_5_0 ps_5_0) Major performance caveat: no Maximum texture size: 16384 Point size range: 1 to 1024 Extensions: EXT_color_buffer_float EXT_disjoint_timer_query_webgl2 EXT_texture_filter_anisotropic OES_texture_float_linear WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context Audio information System sample rate: 48000 Hz Output channels: 2 Output interpretation: speakers Supported decode formats: Ogg Opus (audio/ogg; codecs=opus) WebM Opus (audio/webm; codecs=opus) Ogg Vorbis (audio/ogg; codecs=vorbis) WebM Vorbis (audio/webm; codecs=vorbis) MPEG-4 AAC (audio/mp4; codecs=mp4a.40.5) MP3 (audio/mpeg) FLAC (audio/flac) PCM WAV (audio/wav; codecs=1) Supported encode formats: WebM Opus (audio/webm; codecs=opus) Video information Supported decode formats: WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8) Ogg Theora (video/ogg; codecs=theora) H.264 (video/mp4; codecs=avc1.42E01E) Supported encode formats: WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8)
AshleyScirra commented 5 years ago

This is really complicated... we have a lot of complex code for re-linking references through entire event trees when you do something like drag a local variable to a different scope. During re-linking some conditions/actions are temporarily deactivated and then reactivated to a different variable, which it finds by its name. The problem stems from the re-linking code not being able to distinguish between "deactivated because the variable was moved" and "deactivated because the variable was earlier deleted"; in both cases it finds a variable with the right name and reactivates the condition/action, hence in this issue a deleted action comes back to life.

The worst problem is that it can bring back invalid events that refer to the wrong type variable. I've got a fix for that aspect in the next release since it was straightforward. This prevents the bug happening if the variable type is different, but then if you just recreate the same type variable it still happens. At least in that case all the events are still valid though. It also happens if you move the variable itself (which directly causes re-linking variable references).

I'm not sure what the best approach to properly solve this is, I'll have to think about it a while...

AshleyScirra commented 5 years ago

Note to self: see also issue #3118 for a variant involving functions.

AshleyScirra commented 4 years ago

Another variant: #3951, this time involving the re-linking after undo/redo.

dop2000 commented 2 years ago

@AshleyScirra Could you add a warning message when deleted code has been automatically restored, but may potentially be corrupted? This may be a very serious problem - in my case (as described in issue #5569) the function arguments disappeared in about 70 different events in multiple event sheets. I lost an hour fixing it, and it could have been much worse.

AshleyScirra commented 2 years ago

The problem is the editor currently can't distinguish between different create/destroy cases like undo/redo, drag/drop, and copy/delete/paste. So I don't think we can even add a warning. The editor doesn't know when to show it.

therealPaulPlay commented 1 year ago

I have experienced this bug many times but always thought it was a feature. I used it sometimes, when I needed to change the type of a variable because I accidentally made something e.g a number instead of a string. That was pretty handy, as the actions then reappeared.