Skip to content

lookandfeel: Fix Logout actions

ivan tkachenko requested to merge work/ratijas/logout-actions into master

JavaScript doesn't work that way: functions are only bound to a left-hand-side object when immediately invoked via parenthesis, so the previous code complained about wrong this object being bound to a QML method at runtime. To fix this, store a closure in currentAction instead of an unbound method. Conversely, when calling a stored function an extra pair of parenthesis should be preferred which resets the execution context, to indicate that is not an instance method; though not strictly required because:

arrow functions establish this based on the scope the arrow function is defined within, and the this value does not change based on how the function is invoked.

(c) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Aside from that JS technicality, let's port LogoutButton away from having an action property at all, since they already do have a signal called clicked().

Merge request reports