Make clang-tidy complain a little less

This commit is contained in:
Mm2PL 2023-02-02 21:32:15 +01:00
parent ff49aebf08
commit ee1bb1956b
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
3 changed files with 20 additions and 15 deletions

View file

@ -101,7 +101,9 @@ bool PluginController::tryLoadFromDir(const QDir &pluginDir)
this->load(index, pluginDir, PluginMeta(doc.object()));
return true;
}
void PluginController::openLibrariesFor(lua_State *L, PluginMeta meta)
void PluginController::openLibrariesFor(lua_State *L,
const PluginMeta & /*meta*/)
{
// Stuff to change, remove or hide behind a permission system:
static const std::vector<luaL_Reg> loadedlibs = {
@ -135,12 +137,13 @@ void PluginController::openLibrariesFor(lua_State *L, PluginMeta meta)
}
}
void PluginController::load(QFileInfo index, QDir pluginDir, PluginMeta meta)
void PluginController::load(const QFileInfo &index, const QDir &pluginDir,
const PluginMeta &meta)
{
qCDebug(chatterinoLua) << "Running lua file" << index;
lua_State *l = luaL_newstate();
this->openLibrariesFor(l, meta);
this->loadChatterinoLib(l);
PluginController::openLibrariesFor(l, meta);
PluginController::loadChatterinoLib(l);
auto pluginName = pluginDir.dirName();
auto plugin = std::make_unique<Plugin>(pluginName, l, meta, pluginDir);
@ -154,7 +157,7 @@ void PluginController::load(QFileInfo index, QDir pluginDir, PluginMeta meta)
}
}
this->plugins_.insert({pluginName, std::move(plugin)});
if (!this->isEnabled(pluginName))
if (!PluginController::isEnabled(pluginName))
{
qCInfo(chatterinoLua) << "Skipping loading" << pluginName << "("
<< meta.name << ") because it is disabled";
@ -189,7 +192,7 @@ bool PluginController::reload(const QString &codename)
getApp()->commands->unregisterPluginCommand(cmd);
}
it->second->ownedCommands.clear();
if (this->isEnabled(codename))
if (PluginController::isEnabled(codename))
{
QDir loadDir = it->second->loadDirectory_;
this->plugins_.erase(codename);
@ -209,7 +212,8 @@ void PluginController::callEvery(const QString &functionName)
void PluginController::callEveryWithArgs(
const QString &functionName, int count,
std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)> argCb)
const std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)>
&argCb)
{
for (const auto &[name, plugin] : this->plugins_)
{

View file

@ -30,8 +30,8 @@ public:
void callEvery(const QString &functionName);
void callEveryWithArgs(
const QString &functionName, int count,
std::function<void(const std::unique_ptr<Plugin> &pl, lua_State *L)>
argCb);
const std::function<void(const std::unique_ptr<Plugin> &pl,
lua_State *L)> &argCb);
QString tryExecPluginCommand(const QString &commandName,
const CommandContext &ctx);
@ -56,15 +56,16 @@ public:
}
bool reload(const QString &codename);
bool isEnabled(const QString &codename);
static bool isEnabled(const QString &codename);
private:
void actuallyInitialize();
void load(QFileInfo index, QDir pluginDir, PluginMeta meta);
void loadChatterinoLib(lua_State *l);
void load(const QFileInfo &index, const QDir &pluginDir,
const PluginMeta &meta);
// This function adds lua standard libraries into the state
void openLibrariesFor(lua_State *L, PluginMeta meta);
static void openLibrariesFor(lua_State *L, const PluginMeta & /*meta*/);
static void loadChatterinoLib(lua_State *l);
bool tryLoadFromDir(const QDir &pluginDir);
std::map<QString, std::unique_ptr<Plugin>> plugins_;
};

View file

@ -106,7 +106,7 @@ void PluginsPage::rebuildContent()
pl->addRow("Commands", new QLabel(cmds));
QString enableOrDisableStr = "Enable";
if (getApp()->plugins->isEnabled(codename))
if (PluginController::isEnabled(codename))
{
enableOrDisableStr = "Disable";
}
@ -116,7 +116,7 @@ void PluginsPage::rebuildContent()
enableDisable, &QPushButton::pressed, [name = codename, this]() {
std::vector<QString> val =
getSettings()->enabledPlugins.getValue();
if (getApp()->plugins->isEnabled(name))
if (PluginController::isEnabled(name))
{
val.erase(std::remove(val.begin(), val.end(), name),
val.end());