Code Monkey home page Code Monkey logo

Comments (7)

joshtynjala avatar joshtynjala commented on August 19, 2024

This issue is caused by openfl/openfl#2177

from feathersui-openfl.

brighttank avatar brighttank commented on August 19, 2024

It also occurs if you set the style provider after the component has been initialized. The setter method will call applyStyles because the control is initialized and then applyStyles will get called again on update.

Either way, wouldn't the fix be to not reapply styles if the styleProvider hasn't changed?

from feathersui-openfl.

joshtynjala avatar joshtynjala commented on August 19, 2024

The setter method will call applyStyles because the control is initialized and then applyStyles will get called again on update.

From which line exactly does applyStyles() get called the second time?

from feathersui-openfl.

brighttank avatar brighttank commented on August 19, 2024

From FeathersControl.hx

	private function set_styleProvider(value:IStyleProvider):IStyleProvider {
		if (this._customStyleProvider == value) {
			return this._customStyleProvider;
		}
		this._customStyleProvider = value;
		if (this.initialized) {
			// ignore if we're not initialized yet because it will be handled
			// later. otherwise, apply the new styles immediately.
			this.applyStyles();
		}
		this.setInvalid(InvalidationFlag.STYLES);
		return this._customStyleProvider;
	}

If this.initialized is true then this.applyStyles() will get called. Then the invalidation flag is set which results in it getting called again.

from feathersui-openfl.

joshtynjala avatar joshtynjala commented on August 19, 2024

How does setInvalid(InvalidationFlag.STYLES) cause applyStyles() to get called again?

from feathersui-openfl.

brighttank avatar brighttank commented on August 19, 2024

You're right. I just stepped through the code again. The second call is actually because of the duplicate added to stage event. I'd incorrectly assumed the invalidation was going to applyStyles again.

I still think it would be useful to not clearStyles() if it's not necessary. I'm actually porting a skin class from the Starling version which already guards against duplicate calls. This meant that the styles were getting cleared the second time through and then my skin wasn't reapplying them again.

from feathersui-openfl.

joshtynjala avatar joshtynjala commented on August 19, 2024

I added a guard for the duplicate Event.ADDED_TO_STAGE event.

I need to think some more about adding a guard for clearStyles(). If I were to add something, it would only prevent clearStyles() from being called if _currentStyleProvider were null. I suspect that you are expecting some additional conditions for clearStyles() to be skipped, but any other reason for skipping it could cause some old styles to be left behind that shouldn't be.

from feathersui-openfl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.