MM5 Addon: uitools.getSelectedTracklist().whenLoaded() throws “Read lock not acquired” and returns 0 tracks

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: MM5 Addon: uitools.getSelectedTracklist().whenLoaded() throws “Read lock not acquired” and returns 0 tracks

Re: MM5 Addon: uitools.getSelectedTracklist().whenLoaded() throws “Read lock not acquired” and returns 0 tracks

by PetrCBR » Sat Mar 21, 2026 10:36 am

whenLoaded() returns promise so you need to do something like
in the example for getSelectedTracklist method:

var list = uitools.getSelectedTracklist();
list.whenLoaded()
.then(function () {
// Perform your operations
});

MM5 Addon: uitools.getSelectedTracklist().whenLoaded() throws “Read lock not acquired” and returns 0 tracks

by frogsummer » Sat Mar 21, 2026 10:00 am

Hi all,

I’m developing a MediaMonkey 5 addon and running into a consistent issue retrieving the selected tracklist from an action under Edit Tags.

Environment:
• MediaMonkey version: 2024.2.1.3213
• OS: Windows 11
• Addon type: MM5 script addon (info.json + actions_add.js)
• Entry point: actions_add.js (Edit Tags submenu)

Issue:
When executing an action that calls:
const list = await uitools.getSelectedTracklist().whenLoaded();

I intermittently (and often consistently) receive:
Read lock not acquired! (C:\Sources\MediaMonkey2024_2_1\HTML5Monkey\BaseShared.pas, line 4093)

After this:
• the promise resolves (or fails internally)
• the resulting tracklist is empty (0 tracks)
• downstream logic does not execute

Observed Behavior:
• The action itself executes correctly (confirmed via forced exception / alert)
• The failure occurs specifically when retrieving the selected tracklist
• Happens even with:
• small selections (e.g., 10–20 tracks)
• flat playlist view
• full library view
• Same behavior across multiple attempts

Expected Behavior:
• getSelectedTracklist().whenLoaded() should return the currently selected tracks
• This matches examples seen in forum posts and documentation

Minimal Repro Code:
actions.testSelection = {
title: 'Test Selection',
hotkeyAble: false,
execute: async () => {
try {
const list = await uitools.getSelectedTracklist().whenLoaded();
alert(`Track count: ${list.count}`);
} catch (e) {
alert(`Error: ${e.message}`);
}
}
};

Additional Notes:
• Using uitools.getSelectedTracklist() without whenLoaded() avoids the exception but does not reliably return usable data
• Attempted alternatives:
• app.selection
• app.player.selectedTracks
• window.selection
→ none provided consistent results

Questions:
1. Is this a known issue with selection locking in MM5?
2. Is there a recommended alternative to getSelectedTracklist() for addon actions?
3. Are there specific contexts where selection APIs are safe vs unsafe?
4. Is there a workaround to avoid the read lock error?

Goal:
I’m trying to process selected tracks from an Edit Tags action (batch rating/update scenario).



Thanks in advance—happy to provide additional logs or test builds if needed.

Top