const functions allow mutating variables from UI scope

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!

const functions allow mutating variables from UI scope

Postby Edwin Fomblehun » Sat Feb 16, 2019 3:36 pm

I've got an inventory item to represent stamina and a const function that mutates one of the variables of the class

class ActorStamina : Inventory {
...
protected int _regenTick;
...
void PauseRegeneration(int ticks) const {
_regenTick = ticks;
}
...
}

I have a status bar and I call this function

class PlayerStatusBar : BaseStatusBar {
...
override void Draw (int state, double tic) {
stamina.PauseRegeneration(1000);
}
...
}

I shouldn't be able to modify anything because it's const, but I still can from the UI scope.
Edwin Fomblehun
 

Re: const functions allow mutating variables from UI scope

Postby phantombeta » Sat Feb 16, 2019 3:54 pm

Attached test PK3. Give yourself "Derp" on the console.
I think it's a good idea to fix this as soon as possible. I'd try to help, but for some reason, I can't find the damn code that handles const functions at all.
You do not have the required permissions to view the files attached to this post.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: Brazil, South America, Earth, Orion-Cygnus Arm, Milky Way
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: const functions allow mutating variables from UI scope

Postby phantombeta » Fri Dec 27, 2019 2:18 pm

Bumping this because it's basically nearly a year since it was reported and it seems it was overlooked.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: Brazil, South America, Earth, Orion-Cygnus Arm, Milky Way
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Bugs

Who is online

Users browsing this forum: Lars and 0 guests