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.
Attachments
test.pk3
(621 Bytes) Downloaded 34 times
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 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: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 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: No registered users and 1 guest