Commit ecea8b93 authored by Atul bisht's avatar Atul bisht

[Touchpad KCM] Fix kded crashing at startup

Summary:
When XcbAtom::atom() is called (by kded on key press other than Kded Keyboard shortcuts), m_connection seems to be having null or 0x0 value.
Small check on m_connection solves the issue for me.

BUG: 407614

Test Plan: kded5 do not crashed at startup.

Reviewers: romangg, davidedmundson

Reviewed By: romangg

Subscribers: fvogt, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21278
parent 7fa0f17a
......@@ -366,6 +366,16 @@ bool LibinputTouchpad::isChangedConfig()
return changed;
}
int LibinputTouchpad::touchpadOff()
{
return m_enabled.val;
}
XcbAtom &LibinputTouchpad::touchpadOffAtom()
{
return *m_atoms[QLatin1Literal("enabled")].data();
}
template<typename T>
bool LibinputTouchpad::valueLoader(Prop<T> &prop)
{
......
......@@ -38,6 +38,9 @@ public:
bool getDefaultConfig() override;
bool isChangedConfig() override;
int touchpadOff() override;
XcbAtom &touchpadOffAtom() override;
private:
template<typename T>
......
......@@ -235,6 +235,28 @@ SynapticsTouchpad::SynapticsTouchpad(Display *display, int deviceId): XlibTouchp
m_paramList = synapticsProperties;
}
void SynapticsTouchpad::setTouchpadOff(int touchpadOff)
{
PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0);
if (off.b && *(off.b) != touchpadOff) {
*(off.b) = touchpadOff;
off.set();
}
flush();
}
int SynapticsTouchpad::touchpadOff()
{
PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0);
return off.value(0).toInt();
}
XcbAtom &SynapticsTouchpad::touchpadOffAtom()
{
return m_touchpadOffAtom;
}
double SynapticsTouchpad::getPropertyScale(const QString &name) const
{
if (m_scaleByResX.contains(name) && m_scaleByResY.contains(name)) {
......
......@@ -29,11 +29,16 @@ class SynapticsTouchpad : public QObject, public XlibTouchpad
public:
SynapticsTouchpad(Display *display, int deviceId);
void setTouchpadOff(int touchpadOff) override;
int touchpadOff() override;
XcbAtom &touchpadOffAtom() override;
protected:
double getPropertyScale(const QString &name) const override;
private:
XcbAtom m_capsAtom;
XcbAtom m_capsAtom, m_touchpadOffAtom;
int m_resX, m_resY;
QStringList m_scaleByResX, m_scaleByResY, m_toRadians;
};
......
......@@ -251,29 +251,6 @@ bool XlibTouchpad::enabled()
return enabled.value(0).toBool();
}
void XlibTouchpad::setTouchpadOff(int touchpadOff)
{
PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0);
if (off.b && *(off.b) != touchpadOff) {
*(off.b) = touchpadOff;
off.set();
}
flush();
}
int XlibTouchpad::touchpadOff()
{
PropertyInfo off(m_display, m_deviceId, m_touchpadOffAtom.atom(), 0);
return off.value(0).toInt();
}
XcbAtom& XlibTouchpad::touchpadOffAtom()
{
return m_touchpadOffAtom;
}
const Parameter* XlibTouchpad::findParameter(const QString& name)
{
for (const Parameter *par = m_paramList; par->name; par++) {
......
......@@ -60,10 +60,10 @@ public:
virtual bool isChangedConfig() { return false; }
void setEnabled(bool enable);
bool enabled();
void setTouchpadOff(int touchpadOff);
int touchpadOff();
virtual void setTouchpadOff(int touchpadOff) {}
virtual int touchpadOff() = 0;
XcbAtom &touchpadOffAtom();
virtual XcbAtom &touchpadOffAtom() = 0;
protected:
void loadSupportedProperties(const Parameter *props);
......@@ -78,7 +78,7 @@ protected:
xcb_connection_t *m_connection;
int m_deviceId;
XcbAtom m_floatType, m_enabledAtom, m_touchpadOffAtom;
XcbAtom m_floatType, m_enabledAtom;
QMap<QLatin1String, QSharedPointer<XcbAtom> > m_atoms;
......
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