Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
fix: fixed static global variable causing variable content overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
QxQ authored and QxQ committed Sep 22, 2020
1 parent 942a326 commit e1ba5be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions SimplePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include <QLabel>
#include <QMetaEnum>

bool NaiveProxyPlugin::InitializePlugin(const QString &, const QJsonObject &settings)
bool NaiveProxyPlugin::InitializePlugin(const QString &, const QJsonObject &_settings)
{
this->settings = _settings;
NaiveProxyPluginInstance = this;
emit PluginLog("Initializing NaiveProxy plugin.");
this->settings = settings;
this->outboundHandler = std::make_unique<NaiveProxyOutboundHandler>();
this->eventHandler = std::make_unique<NaiveEventHandler>();
this->kernelInterface = std::make_shared<NaiveKernelInterface>();
Expand Down
4 changes: 3 additions & 1 deletion SimplePlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace Qv2rayPlugin;

class NaiveProxyPlugin
: public QObject
, Qv2rayInterface
, public Qv2rayInterface
{
Q_INTERFACES(Qv2rayPlugin::Qv2rayInterface)
Q_PLUGIN_METADATA(IID Qv2rayInterface_IID)
Expand Down Expand Up @@ -38,3 +38,5 @@ class NaiveProxyPlugin
void PluginLog(const QString &) const override;
void PluginErrorMessageBox(const QString &, const QString &) const override;
};

DECLARE_PLUGIN_INSTANCE(NaiveProxyPlugin);
6 changes: 3 additions & 3 deletions core/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ NaiveProxyKernel::NaiveProxyKernel() : Qv2rayPlugin::PluginKernel()

bool NaiveProxyKernel::StartKernel()
{
const auto executablePath = pluginInstance->GetSettngs()["kernelPath"].toString();
const auto executablePath = NaiveProxyPluginInstance->GetSettngs()["kernelPath"].toString();
if (!QFile::exists(executablePath))
{
pluginInstance->PluginErrorMessageBox(tr("Naive!"),
tr("We cannot find your NaiveProxy kernel. Please configure it in the plugin settings."));
NaiveProxyPluginInstance->PluginErrorMessageBox(
tr("Naive!"), tr("We cannot find your NaiveProxy kernel. Please configure it in the plugin settings."));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion interface
3 changes: 2 additions & 1 deletion ui/SettingsWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ class SettingsWidget
}
textKernelPath->setText(root.value("kernelPath").toString());
}

QJsonObject GetSettings() override
{
return root;
}

protected:
void changeEvent(QEvent *e);
void changeEvent(QEvent *e) override;

private slots:
void on_textKernelPath_textEdited(const QString &arg1);
Expand Down

0 comments on commit e1ba5be

Please sign in to comment.