Use closures with engine.beginTimer in MIDI Script

Bug #838516 reported by Phillip Whelan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Wishlist
Phillip Whelan
1.10
Fix Released
Wishlist
Phillip Whelan
1.11
Fix Released
Wishlist
Phillip Whelan

Bug Description

It would be great to pass functions directly to engine.beginTimer and have it use the same context where the timer is being registered.

Here is an example of what engine.beginTimer can do now

    function doTimer() {
        print("Executed Timer");
    }
    engine.beginTimer(200, "doTimer", 1);

With closures the same code can also be written as such:

    engine.beginTimer(200, function() { print("Executed Timer") }, 1);

Also since the context is being reused this same code actually works:

    function doMidi() {
        this.value = 1;
        engine.beginTimer(200, function() { if (this.value) print("Executed Timer"); }, 1);
    }

I have attached a patch which can be applied to trunk that accomplishes this functionality.

Tags: midiscript

Related branches

Revision history for this message
Phillip Whelan (pwhelan) wrote :
Changed in mixxx:
status: New → Confirmed
Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Hey Phil,

I see you only store 'this' for function arguments to beginTimer. Is there any reason not to also apply string arguments with the same 'this' as the beginTimer() caller environment's 'this'?

RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Confirmed → Triaged
status: Triaged → Fix Committed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Sean M. Pappalardo (pegasus-renegadetech) wrote :

Phillip, would you please re-create this patch against the features_controllerAbstraction branch's ControllerEngine? I started to manually merge it but I don't want to screw anything up.

Changed in mixxx:
milestone: 1.10.0 → none
status: Fix Released → In Progress
Revision history for this message
Phillip Whelan (pwhelan) wrote :

I actually have a working copy with most of the MIDI Script improvements in them merged with CA. I need to spruce it up and re-merge since it has fallen out of sync.

RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: In Progress → Fix Committed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/5976

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.