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

Commit e1ba5be

Browse files
QxQQxQ
authored andcommitted
fix: fixed static global variable causing variable content overwrite
1 parent 942a326 commit e1ba5be

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

SimplePlugin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#include <QLabel>
1010
#include <QMetaEnum>
1111

12-
bool NaiveProxyPlugin::InitializePlugin(const QString &, const QJsonObject &settings)
12+
bool NaiveProxyPlugin::InitializePlugin(const QString &, const QJsonObject &_settings)
1313
{
14+
this->settings = _settings;
15+
NaiveProxyPluginInstance = this;
1416
emit PluginLog("Initializing NaiveProxy plugin.");
15-
this->settings = settings;
1617
this->outboundHandler = std::make_unique<NaiveProxyOutboundHandler>();
1718
this->eventHandler = std::make_unique<NaiveEventHandler>();
1819
this->kernelInterface = std::make_shared<NaiveKernelInterface>();

SimplePlugin.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using namespace Qv2rayPlugin;
99

1010
class NaiveProxyPlugin
1111
: public QObject
12-
, Qv2rayInterface
12+
, public Qv2rayInterface
1313
{
1414
Q_INTERFACES(Qv2rayPlugin::Qv2rayInterface)
1515
Q_PLUGIN_METADATA(IID Qv2rayInterface_IID)
@@ -38,3 +38,5 @@ class NaiveProxyPlugin
3838
void PluginLog(const QString &) const override;
3939
void PluginErrorMessageBox(const QString &, const QString &) const override;
4040
};
41+
42+
DECLARE_PLUGIN_INSTANCE(NaiveProxyPlugin);

core/Kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ NaiveProxyKernel::NaiveProxyKernel() : Qv2rayPlugin::PluginKernel()
2121

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

ui/SettingsWidget.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class SettingsWidget
3232
}
3333
textKernelPath->setText(root.value("kernelPath").toString());
3434
}
35+
3536
QJsonObject GetSettings() override
3637
{
3738
return root;
3839
}
3940

4041
protected:
41-
void changeEvent(QEvent *e);
42+
void changeEvent(QEvent *e) override;
4243

4344
private slots:
4445
void on_textKernelPath_textEdited(const QString &arg1);

0 commit comments

Comments
 (0)