Browse Source

Throw Exception when Module::getPatchStorageDirectory() is called when Module is not added to Engine.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
deacbb50dc
2 changed files with 7 additions and 3 deletions
  1. +5
    -3
      include/engine/Module.hpp
  2. +2
    -0
      src/engine/Module.cpp

+ 5
- 3
include/engine/Module.hpp View File

@@ -219,10 +219,12 @@ struct Module {
}

/** Creates and returns the module's patch storage directory path.
Since the directory is created when this is called, do not call it frequently or in an audio/engine thread such as process().
Do not call this method in process() since filesystem operations block the audio thread. Calling getPatchStorageDirectory() is acceptable.

The Module must be added to Engine before this can be called, so it cannot be called in your Module constructor.
Override onAdd() instead.
Throws an Exception if Module is not yet added to the Engine.
Therefore, you may not call these methods in your Module constructor.
Instead, create your patch storage files in the onAdd() event and close them in the onRemove() event.
If patch storage files are not removed, they will be garbage collected when user saves the patch.
*/
std::string createPatchStorageDirectory();
std::string getPatchStorageDirectory();


+ 2
- 0
src/engine/Module.cpp View File

@@ -90,6 +90,8 @@ std::string Module::createPatchStorageDirectory() {


std::string Module::getPatchStorageDirectory() {
if (id < 0)
throw Exception("getPatchStorageDirectory() cannot be called unless Module belongs to Engine and thus has a valid ID");
return system::join(APP->patch->autosavePath, "modules", std::to_string(id));
}



Loading…
Cancel
Save