Fix crash when systemd unit status changes when settings page has already been destroyed
This commit is contained in:
parent
e9a278a248
commit
69f466be66
|
@ -11,7 +11,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
|
||||||
set(META_GUI_OPTIONAL false)
|
set(META_GUI_OPTIONAL false)
|
||||||
set(META_VERSION_MAJOR 1)
|
set(META_VERSION_MAJOR 1)
|
||||||
set(META_VERSION_MINOR 1)
|
set(META_VERSION_MINOR 1)
|
||||||
set(META_VERSION_PATCH 8)
|
set(META_VERSION_PATCH 9)
|
||||||
set(META_VERSION_EXACT_SONAME ON)
|
set(META_VERSION_EXACT_SONAME ON)
|
||||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||||
|
|
||||||
|
|
|
@ -1209,6 +1209,10 @@ SystemdOptionPage::SystemdOptionPage(QWidget *parentWidget)
|
||||||
|
|
||||||
SystemdOptionPage::~SystemdOptionPage()
|
SystemdOptionPage::~SystemdOptionPage()
|
||||||
{
|
{
|
||||||
|
QObject::disconnect(m_unitChangedConn);
|
||||||
|
QObject::disconnect(m_descChangedConn);
|
||||||
|
QObject::disconnect(m_statusChangedConn);
|
||||||
|
QObject::disconnect(m_enabledChangedConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *SystemdOptionPage::setupWidget()
|
QWidget *SystemdOptionPage::setupWidget()
|
||||||
|
@ -1218,14 +1222,18 @@ QWidget *SystemdOptionPage::setupWidget()
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
QObject::connect(ui()->syncthingUnitLineEdit, &QLineEdit::textChanged, m_service, &SyncthingService::setUnitName);
|
QObject::connect(ui()->syncthingUnitLineEdit, &QLineEdit::textChanged, m_service, &SyncthingService::setUnitName);
|
||||||
QObject::connect(ui()->systemUnitCheckBox, &QCheckBox::clicked, m_service, bind(&SystemdOptionPage::handleSystemUnitChanged, this));
|
|
||||||
QObject::connect(ui()->startPushButton, &QPushButton::clicked, m_service, &SyncthingService::start);
|
QObject::connect(ui()->startPushButton, &QPushButton::clicked, m_service, &SyncthingService::start);
|
||||||
QObject::connect(ui()->stopPushButton, &QPushButton::clicked, m_service, &SyncthingService::stop);
|
QObject::connect(ui()->stopPushButton, &QPushButton::clicked, m_service, &SyncthingService::stop);
|
||||||
QObject::connect(ui()->enablePushButton, &QPushButton::clicked, m_service, &SyncthingService::enable);
|
QObject::connect(ui()->enablePushButton, &QPushButton::clicked, m_service, &SyncthingService::enable);
|
||||||
QObject::connect(ui()->disablePushButton, &QPushButton::clicked, m_service, &SyncthingService::disable);
|
QObject::connect(ui()->disablePushButton, &QPushButton::clicked, m_service, &SyncthingService::disable);
|
||||||
QObject::connect(m_service, &SyncthingService::descriptionChanged, bind(&SystemdOptionPage::handleDescriptionChanged, this, _1));
|
m_unitChangedConn
|
||||||
QObject::connect(m_service, &SyncthingService::stateChanged, bind(&SystemdOptionPage::handleStatusChanged, this, _1, _2, _3));
|
= QObject::connect(ui()->systemUnitCheckBox, &QCheckBox::clicked, m_service, bind(&SystemdOptionPage::handleSystemUnitChanged, this));
|
||||||
QObject::connect(m_service, &SyncthingService::unitFileStateChanged, bind(&SystemdOptionPage::handleEnabledChanged, this, _1));
|
m_descChangedConn
|
||||||
|
= QObject::connect(m_service, &SyncthingService::descriptionChanged, bind(&SystemdOptionPage::handleDescriptionChanged, this, _1));
|
||||||
|
m_statusChangedConn
|
||||||
|
= QObject::connect(m_service, &SyncthingService::stateChanged, bind(&SystemdOptionPage::handleStatusChanged, this, _1, _2, _3));
|
||||||
|
m_enabledChangedConn
|
||||||
|
= QObject::connect(m_service, &SyncthingService::unitFileStateChanged, bind(&SystemdOptionPage::handleEnabledChanged, this, _1));
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,10 @@ void handleDescriptionChanged(const QString &description);
|
||||||
void handleStatusChanged(const QString &activeState, const QString &subState, CppUtilities::DateTime activeSince);
|
void handleStatusChanged(const QString &activeState, const QString &subState, CppUtilities::DateTime activeSince);
|
||||||
void handleEnabledChanged(const QString &unitFileState);
|
void handleEnabledChanged(const QString &unitFileState);
|
||||||
Data::SyncthingService *const m_service;
|
Data::SyncthingService *const m_service;
|
||||||
|
QMetaObject::Connection m_unitChangedConn;
|
||||||
|
QMetaObject::Connection m_descChangedConn;
|
||||||
|
QMetaObject::Connection m_statusChangedConn;
|
||||||
|
QMetaObject::Connection m_enabledChangedConn;
|
||||||
END_DECLARE_OPTION_PAGE
|
END_DECLARE_OPTION_PAGE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue