Merge PR #6: Fix a deadlock and some typos

This commit is contained in:
Jenkins nymea 2021-11-07 00:39:46 +01:00
commit cd11846be4
5 changed files with 15 additions and 11 deletions

View File

@ -164,7 +164,7 @@ void GpioButton::onTimeout()
emit longPressed();
}
void GpioButton::onInterruptOccured(bool value)
void GpioButton::onInterruptOccurred(bool value)
{
if (value) {
// Pressed
@ -206,7 +206,7 @@ bool GpioButton::enable()
m_monitor = nullptr;
return false;
}
connect(m_monitor, &GpioMonitor::interruptOccured, this, &GpioButton::onInterruptOccured);
connect(m_monitor, &GpioMonitor::interruptOccurred, this, &GpioButton::onInterruptOccurred);
// Setup timer, if this timer reaches timeout, a long pressed happend
m_timer = new QTimer(this);

View File

@ -77,7 +77,7 @@ signals:
private slots:
void onTimeout();
void onInterruptOccured(bool value);
void onInterruptOccurred(bool value);
public slots:
bool enable();

View File

@ -147,10 +147,10 @@ void GpioMonitor::setValue(Gpio::Value value)
switch (m_value) {
case Gpio::ValueLow:
emit interruptOccured(false);
emit interruptOccurred(false);
break;
case Gpio::ValueHigh:
emit interruptOccured(true);
emit interruptOccurred(true);
break;
default:
break;
@ -219,8 +219,12 @@ void GpioMonitor::run()
}
// Check if we should stop the thread
QMutexLocker stopLocker(&m_stopMutex);
if (m_stop) break;
m_stopMutex.lock();
if (m_stop) {
m_stopMutex.unlock();
break;
}
m_stopMutex.unlock();
// No interrupt occured
if (rc == 0)
@ -264,7 +268,7 @@ void GpioMonitor::onThreadFinished()
/*! Returns true, if this GpioMonitor was enabled successfully. */
bool GpioMonitor::enable()
{
qCDebug(dcGpio()) << "Enable gpio monitor";
qCDebug(dcGpio()) << "Enabling gpio monitor";
if (isRunning()) {
qCWarning(dcGpio()) << "This GPIO monitor is already running.";
return true;
@ -287,7 +291,7 @@ bool GpioMonitor::enable()
/*! Disables this GpioMonitor. The \l{interruptOccured()} signal will not be emitted any more and the Gpio will be unexported. */
void GpioMonitor::disable()
{
qCDebug(dcGpio()) << "Disable gpio monitor";
qCDebug(dcGpio()) << "Disabling gpio monitor";
// Stop the thread if not already disabled
QMutexLocker locker(&m_stopMutex);
if (m_stop) return;

View File

@ -76,7 +76,7 @@ protected:
void run() override;
signals:
void interruptOccured(bool value);
void interruptOccurred(bool value);
void enabledChanged(bool enabled);
private slots:

View File

@ -170,7 +170,7 @@ int main(int argc, char *argv[])
});
// Inform about interrupt
QObject::connect(monitor, &GpioMonitor::interruptOccured, [gpioNumber](bool value) {
QObject::connect(monitor, &GpioMonitor::interruptOccurred, [gpioNumber](bool value) {
qDebug() << "GPIO" << gpioNumber << "interrupt occured. Current value:" << (value ? "1" : "0");
});