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

Get help for different MediaMonkey v5 / v2024 Addons.

Moderators: jiri, drakinite, Addon Administrators

frogsummer
Posts: 1
Joined: Sat Mar 21, 2026 9:41 am

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

Post by frogsummer »

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.
PetrCBR
Posts: 1787
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

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

Post by PetrCBR »

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
});
How to make a debuglog - step 4b: viewtopic.php?f=30&t=86643
Post Reply