Commit 165a60b3 authored by David Redondo's avatar David Redondo 🏎
Browse files

Do not call libsensors init or cleanup functions from plugin

Doing so multiple times in the same process will lead to crashes.
parent 8208a151
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <systemstats/SensorContainer.h> #include <systemstats/SensorContainer.h>
#include <systemstats/SensorPlugin.h>
#ifdef HAVE_SENSORS #ifdef HAVE_SENSORS
#include <sensors/sensors.h> #include <sensors/sensors.h>
...@@ -127,7 +128,9 @@ void LinuxCpuPluginPrivate::update() ...@@ -127,7 +128,9 @@ void LinuxCpuPluginPrivate::update()
void LinuxCpuPluginPrivate::addSensors() void LinuxCpuPluginPrivate::addSensors()
{ {
#ifdef HAVE_SENSORS #ifdef HAVE_SENSORS
sensors_init(nullptr); if (!KSysGuard::SensorPlugin::initLibSensors()) {
return;
}
int number = 0; int number = 0;
while (const sensors_chip_name * const chipName = sensors_get_detected_chips(nullptr, &number)) { while (const sensors_chip_name * const chipName = sensors_get_detected_chips(nullptr, &number)) {
char name[100]; char name[100];
......
...@@ -20,7 +20,7 @@ LmSensorsPlugin::LmSensorsPlugin(QObject *parent, const QVariantList &args) ...@@ -20,7 +20,7 @@ LmSensorsPlugin::LmSensorsPlugin(QObject *parent, const QVariantList &args)
: KSysGuard::SensorPlugin(parent, args) : KSysGuard::SensorPlugin(parent, args)
{ {
auto container = new KSysGuard::SensorContainer(QStringLiteral("lmsensors"), i18n( "Hardware Sensors" ), this); auto container = new KSysGuard::SensorContainer(QStringLiteral("lmsensors"), i18n( "Hardware Sensors" ), this);
if (sensors_init(nullptr) != 0) { if (!initLibSensors()) {
return; return;
} }
...@@ -50,7 +50,6 @@ LmSensorsPlugin::LmSensorsPlugin(QObject *parent, const QVariantList &args) ...@@ -50,7 +50,6 @@ LmSensorsPlugin::LmSensorsPlugin(QObject *parent, const QVariantList &args)
LmSensorsPlugin::~LmSensorsPlugin() LmSensorsPlugin::~LmSensorsPlugin()
{ {
sensors_cleanup();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment