Skip to content

Engine.loadUserPreset(string) silently fails for paths without ".preset" extension #987

@weavermedia

Description

@weavermedia

Engine.loadUserPreset(var file) does not append the .preset extension when given a relative path string without one, contrary to the documented "extension auto-appended" behaviour. The result is a silent failure in exported plugins (the reportScriptError has no visible console there).

In ScriptingApi.cpp (ScriptingApi::Engine::loadUserPreset, ~line 3187):

userPresetToLoad = userPresetRoot.getChildFile(file.toString());

if (userPresetToLoad.hasFileExtension(".preset"))
    userPresetToLoad = userPresetToLoad.withFileExtension(".preset");

The extension is only "added" when the string already ends in .preset, making the block a no-op. For extensionless input the path stays bare, existsAsFile() is false, and it bails via reportScriptError(... "doesn't exist").

This is easy to hit because Engine.getUserPresetList() returns paths without the extension, so the natural round-trip fails:

var list = Engine.getUserPresetList();   // e.g. ["00 INIT", "01", "02"]
Engine.loadUserPreset(list[1]);          // silently fails - resolves to ".../UserPresets/01"
Engine.loadUserPreset(list[1] + ".preset"); // works (caller-side workaround)

Suggested fix

Append .preset when the resolved file lacks it, instead of when it already has it:

if (!userPresetToLoad.hasFileExtension(".preset"))
    userPresetToLoad = userPresetToLoad.withFileExtension(".preset");

Found on the frontend/exported path (HISE current master, macOS), but the logic is platform-independent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions