线程退出

This commit is contained in:
jzxc95 2023-05-22 15:29:47 +08:00
parent bdefd77302
commit 4f81e889e3
1 changed files with 20 additions and 4 deletions

View File

@ -88,11 +88,25 @@ int main(int argc, char *argv[])
QApplication::setQuitOnLastWindowClosed(false);
QThread thread;
QDBusInterface interface("com.kylin.kylinvpn",
"/com/kylin/kylinvpn",
"com.kylin.kylinvpn",
QDBusConnection::sessionBus());
if(interface.isValid()) {
return 0;
}
QThread *thread = new QThread();
KyNetworkResourceManager *p_networkResource = KyNetworkResourceManager::getInstance();
p_networkResource->moveToThread(&thread);
QObject::connect(&thread, SIGNAL(started()), p_networkResource, SLOT(onInitNetwork()));
thread.start();
p_networkResource->moveToThread(thread);
QObject::connect(thread, &QThread::started, p_networkResource, &KyNetworkResourceManager::onInitNetwork);
QObject::connect(&a,&QtSingleApplication::aboutToQuit, thread, &QThread::quit);
QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater);
QObject::connect(thread, &QThread::finished, [=](){
qDebug() << "release" ;
p_networkResource->Release();
});
thread->start();
// Internationalization
QString locale = QLocale::system().name();
@ -119,6 +133,8 @@ int main(int argc, char *argv[])
::usleep(1000);
}
vpnObject vpnobject;
a.setActivationWindow(&vpnobject);
vpnobject.setProperty("useStyleWindowManager", false); //禁用拖动