我有一个程序,总经理启动qml界面。
这是我的构造函数:
this->m_viewer = ShapedWindows::getInstance();
this->m_comManager = new CComManager(0x80);
this->m_convert = new CDataConverter();
this->m_configGenerator = new ConfigurationGenerator();
this->m_workedThread = new QThread();
创建我的UI
m_viewer->setColor("background:transparent"); //remove background
m_viewer->engine()->rootContext()->setContextProperty("tr", &m_tr);
m_viewer->engine()->rootContext()->setContextProperty("configGene", m_configGenerator);
m_viewer->engine()->rootContext()->setContextProperty("generalManager", this);
m_viewer->setMainQmlFile(QStringLiteral("qml/MyApp/HomePage.qml"));
m_viewer->setFlags (Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
m_viewer->setIcon(QIcon("qml/MyApp/images/Logo.bmp"));
m_viewer->setTitle("MyApp");
m_viewer->showExpanded();
m_tr.setLanguage("en");
m_configGenerator->initialise();
this->m_comManager->moveToThread(this->m_workedThread);
this->m_convert->moveToThread(this->m_workedThread);
this->m_configGenerator->moveToThread(this->m_workedThread);
this->moveToThread(this->m_workedThread);
this->m_workedThread->start();
当我们点击按钮时,我发送了这个:
emit this->currentActionChanged("Connexion en cours ...");
if(this->m_comManager->StartCom(937500, 3, 0x81, 3, 0xC1)){
emit this->connexionStateChanged(true);
emit this->currentActionChanged("Connexion réussie");
vector<char> memoryAdd;
memoryAdd.push_back(0x00);
memoryAdd.push_back(0x00);
memoryAdd.push_back(0xA0);
QByteArray dataRead;
emit this->currentActionChanged("Lecture de la carte en cours ...");
this->m_comManager->RMBA(7, 0x23, 3, 0x63, memoryAdd, 12, dataRead);
emit this->currentActionChanged("Lecture de la carte terminée");
if(0 < dataRead.size()){
vector<string> config = this->m_convert->ConvertToString(dataRead);
this->m_configGenerator->setConfig(config);
}
Sleep(1000);
emit this->connexionStateChanged(!this->m_comManager->StopCom(3, 0x82, 3, 0xC2));
emit this->currentActionChanged("Déconnexion réussie");
}
然后我在一个新线程中设置我的generalManager。其他对象设置为此新线程,但不是我的IHM类。
问题是当我从第二个线程中的类发出信号时,作为generalManager信号,我的应用程序崩溃了。
请注意此问题ASSERT:“engine-&gt; jsStackTop&gt; = mark”在文件.... \ include \ QtQml \ 5.2.0 \ QtQml / private /../../../ .. /../src/qml/jsruntime/qv4scopedvalue_p.h,第74行