Skip to content

Commit 289e66a

Browse files
committed
fix potential crash on exit in REAPER < 6.67 due to API registration keys being invalidated
Fixes #56
1 parent dcbbf24 commit 289e66a

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/api.cpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,14 @@ APIReg::APIReg(const APIFunc *func)
2929
: m_func(func),
3030
m_impl(KEY("API")), m_vararg(KEY("APIvararg")), m_help(KEY("APIdef"))
3131
{
32-
registerFunc();
32+
plugin_register(m_impl.c_str(), m_func->cImpl);
33+
plugin_register(m_vararg.c_str(), m_func->reascriptImpl);
34+
plugin_register(m_help.c_str(), m_func->definition);
3335
}
3436

3537
APIReg::~APIReg()
3638
{
37-
m_impl.insert(m_impl.begin(), '-');
38-
m_vararg.insert(m_vararg.begin(), '-');
39-
m_help.insert(m_help.begin(), '-');
40-
41-
registerFunc();
42-
}
43-
44-
void APIReg::registerFunc() const
45-
{
46-
plugin_register(m_impl.c_str(), m_func->cImpl);
47-
plugin_register(m_vararg.c_str(), m_func->reascriptImpl);
48-
plugin_register(m_help.c_str(), m_func->definition);
39+
plugin_register(("-" + m_impl).c_str(), m_func->cImpl);
40+
plugin_register(("-" + m_vararg).c_str(), m_func->reascriptImpl);
41+
plugin_register(("-" + m_help).c_str(), m_func->definition);
4942
}

src/api.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ class APIReg {
3434
~APIReg();
3535

3636
private:
37-
void registerFunc() const;
38-
3937
const APIFunc *m_func;
4038

41-
// plugin_register requires these to not be temporaries
39+
// REAPER < 6.67 requires these strings to remain valid after registering
4240
std::string m_impl;
4341
std::string m_vararg;
4442
std::string m_help;

0 commit comments

Comments
 (0)