mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Use Plugin destructor to call lua_close in most cases
reloading still needs manual closing
This commit is contained in:
parent
26a5a24eea
commit
f12b964f59
3 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,9 @@
|
|||
#include "Plugin.hpp"
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
# include "lua.h"
|
||||
|
||||
namespace chatterino {
|
||||
bool Plugin::registerCommand(const QString &name, const QString &functionName)
|
||||
{
|
||||
|
@ -27,5 +30,14 @@ std::set<QString> Plugin::listRegisteredCommands()
|
|||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Plugin::~Plugin()
|
||||
{
|
||||
if (this->state_ != nullptr)
|
||||
{
|
||||
lua_close(this->state_);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
#endif
|
||||
|
|
|
@ -125,6 +125,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
~Plugin();
|
||||
|
||||
bool registerCommand(const QString &name, const QString &functionName);
|
||||
|
||||
std::set<QString> listRegisteredCommands();
|
||||
|
|
|
@ -35,11 +35,6 @@ void PluginController::initialize(Settings &settings, Paths &paths)
|
|||
else
|
||||
{
|
||||
// uninitialize plugins
|
||||
for (const auto &[codename, plugin] : this->plugins_)
|
||||
{
|
||||
this->reload(codename);
|
||||
}
|
||||
// can safely delete them now, after lua freed its stuff
|
||||
this->plugins_.clear();
|
||||
}
|
||||
});
|
||||
|
@ -54,6 +49,7 @@ void PluginController::actuallyInitialize()
|
|||
<< "Loading plugins disabled via Setting, skipping";
|
||||
return;
|
||||
}
|
||||
this->plugins_.clear();
|
||||
auto dir = QDir(getPaths()->pluginsDirectory);
|
||||
qCDebug(chatterinoLua) << "Loading plugins in" << dir.path();
|
||||
for (const auto &info : dir.entryInfoList(QDir::NoDotAndDotDot))
|
||||
|
|
Loading…
Reference in a new issue