Candle icon indicating copy to clipboard operation
Candle copied to clipboard

#RadialLightFix deconstructor problem along with Access Violations

Open EOSource opened this issue 2 years ago • 1 comments

Hello, when i have this enabled with static /mt option compiled with Visual Studio 2019 .lib also compiled with /MT

Randomly sometimes the deconstructor gets called without warning and crashes while trying to draw the radialight

I completely removed the deconstructor and decided to call it manually and its fixed

100% The deconstructor was at fault and being called "Randomly",, this was happening with just a simple radiallight being initalized and drawn like so:

`// create a light source
		candle::RadialLight light;
		light.setRange(150);
		this->lightsources.push_back(light);`

candle::LightingArea fog(candle::LightingArea::FOG,
				sf::Vector2f(0.f, 0.f),
				sf::Vector2f(680, 480.f));
				fog.setAreaColor(sf::Color::Black);
				fog.setAreaOpacity(fogopacity);

				fog.clear();
				for (int i = 0; i < this->lightsources.size(); ++i)
				{
					fog.draw(lightsources[i]);//would randomly deconstruct this and then draw and then crash
				}
				for (int i = 0; i < this->lightsources2.size(); ++i)
				{
					fog.draw(lightsources2[i]);
				}
				fog.display();

				Device->draw(fog);

And here was the modifications i made to fix the error in the Memory Module / .lib image

SFML Event Closed: image

Which results in: image

image

EOSource avatar Nov 10 '21 02:11 EOSource

Mmm this is a though one. I don't know what's causing this random destructor calls... and for some reason I'm not able to reproduce them. I think I need to test it with different compilers to see what's wrong. I just warn you that if you wanted to add that to a PR I would have to decline it, because although it works for you, it would cause compatibility problems with the existent library. But I'm happy to see that at least you have fixed it for you. Thank you, @EOSource . I'll report here if some changes are made that might solve this problem.

MiguelMJ avatar Nov 10 '21 07:11 MiguelMJ