C++ / build (pull_request) Failing after 15s
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 28s
Python / lint-format (pull_request) Successful in 45s
Python / test (pull_request) Successful in 38s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m45s
36 lines
555 B
C++
36 lines
555 B
C++
#include "serviceref.hpp"
|
|
|
|
#include "service.hpp"
|
|
|
|
namespace ZShell::services {
|
|
|
|
ServiceRef::ServiceRef(Service* service, QObject* parent)
|
|
: QObject(parent), m_service(service) {
|
|
if (m_service) {
|
|
m_service->ref(this);
|
|
}
|
|
}
|
|
|
|
Service* ServiceRef::service() const {
|
|
return m_service;
|
|
}
|
|
|
|
void ServiceRef::setService(Service* service) {
|
|
if (m_service == service) {
|
|
return;
|
|
}
|
|
|
|
if (m_service) {
|
|
m_service->unref(this);
|
|
}
|
|
|
|
m_service = service;
|
|
emit serviceChanged();
|
|
|
|
if (m_service) {
|
|
m_service->ref(this);
|
|
}
|
|
}
|
|
|
|
} // namespace ZShell::services
|