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
26 lines
460 B
C++
26 lines
460 B
C++
#include "service.hpp"
|
|
|
|
#include <qdebug.h>
|
|
#include <qpointer.h>
|
|
|
|
namespace ZShell::services {
|
|
|
|
Service::Service(QObject* parent) : QObject(parent) {}
|
|
|
|
void Service::ref(QObject* sender) {
|
|
if (m_refs.isEmpty()) {
|
|
start();
|
|
}
|
|
|
|
QObject::connect(sender, &QObject::destroyed, this, &Service::unref);
|
|
m_refs << sender;
|
|
}
|
|
|
|
void Service::unref(QObject* sender) {
|
|
if (m_refs.remove(sender) && m_refs.isEmpty()) {
|
|
stop();
|
|
}
|
|
}
|
|
|
|
} // namespace ZShell::services
|