mirror of
https://github.com/QuasarApp/Patronum.git
synced 2025-05-11 14:39:34 +00:00
fix sockets
This commit is contained in:
parent
8a076993d1
commit
d2751d5d7b
15
.gitignore
vendored
15
.gitignore
vendored
@ -53,3 +53,18 @@ compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
#cmake
|
||||
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
*_autogen
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "PServiceBase.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTimer>
|
||||
#include "PController.h"
|
||||
#include "serviceprivate.h"
|
||||
@ -75,12 +76,14 @@ void ServiceBase::onPause() {
|
||||
sendResuylt("This function not supported");
|
||||
}
|
||||
|
||||
Controller *ServiceBase::controller() const {
|
||||
Controller *ServiceBase::controller() {
|
||||
if (_controller)
|
||||
return _controller;
|
||||
|
||||
return new Controller(_serviceName,
|
||||
QuasarAppUtils::Params::getCurrentExecutable());
|
||||
_controller = new Controller(_serviceName,
|
||||
QuasarAppUtils::Params::getCurrentExecutable());
|
||||
|
||||
return _controller;
|
||||
}
|
||||
|
||||
int ServiceBase::exec() {
|
||||
@ -88,24 +91,26 @@ int ServiceBase::exec() {
|
||||
createApplication();
|
||||
}
|
||||
|
||||
if (!QuasarAppUtils::Params::customParamasSize()) {
|
||||
bool fExec = QuasarAppUtils::Params::isEndable("exec") || QuasarAppUtils::Params::isDebugBuild();
|
||||
|
||||
if (!(QuasarAppUtils::Params::customParamasSize() || fExec)) {
|
||||
return controller()->startDetached();
|
||||
}
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("exec")) {
|
||||
if (fExec) {
|
||||
QTimer::singleShot(0, [this](){
|
||||
onStart();
|
||||
d_ptr->listen();
|
||||
|
||||
});
|
||||
} else {
|
||||
QTimer::singleShot(0, [this](){
|
||||
if (!controller()->send()) {
|
||||
_core->exit(static_cast<int>(ControllerError::ServiceUnavailable));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, [this](){
|
||||
if (!controller()->send()) {
|
||||
_core->exit(static_cast<int>(ControllerError::ServiceUnavailable));
|
||||
}
|
||||
});
|
||||
|
||||
return _core->exec();
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ protected:
|
||||
* @brief controller
|
||||
* @return own controller instance;
|
||||
*/
|
||||
Controller *controller() const;
|
||||
Controller *controller();
|
||||
|
||||
QCoreApplication *_core = nullptr;
|
||||
private:
|
||||
|
@ -19,7 +19,15 @@ LocalSocket::LocalSocket(const QString &target, QObject *ptr):
|
||||
}
|
||||
|
||||
LocalSocket::~LocalSocket() {
|
||||
if (m_server) {
|
||||
m_server->close();
|
||||
delete m_server;
|
||||
}
|
||||
|
||||
if (m_socket) {
|
||||
m_socket->close();
|
||||
delete m_socket;
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalSocket::registerSokcet(QLocalSocket *socket) {
|
||||
@ -105,10 +113,11 @@ void LocalSocket::handleReadyRead() {
|
||||
|
||||
void LocalSocket::handleIncomming() {
|
||||
if (m_socket) {
|
||||
m_socket->disconnect();
|
||||
m_socket->close();
|
||||
m_socket->deleteLater();
|
||||
m_socket = nullptr;
|
||||
}
|
||||
|
||||
registerSokcet(m_server->nextPendingConnection());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user