凡科网站建站教程,做静态网站的步骤,主机公园wordpress,天猫店铺申请条件及费用问题
在多线程场景中#xff0c;使用QSerialPort,QTcpSocket等QIODevice设备时出现报Cannot create children for a parent that is in a different thread
分析
QObject构造函数中会检查父对象的线程数据与当前对象的线程数据是否一致
static bool check_parent_thread(Q…问题
在多线程场景中使用QSerialPort,QTcpSocket等QIODevice设备时出现报Cannot create children for a parent that is in a different thread
分析
QObject构造函数中会检查父对象的线程数据与当前对象的线程数据是否一致
static bool check_parent_thread(QObject *parent,QThreadData *parentThreadData,QThreadData *currentThreadData)
{if (parent parentThreadData ! currentThreadData) {QThread *parentThread parentThreadData-thread.loadAcquire();QThread *currentThread currentThreadData-thread.loadAcquire();qWarning(QObject: Cannot create children for a parent that is in a different thread.\n(Parent is %s(%p), parents thread is %s(%p), current thread is %s(%p),parent-metaObject()-className(),parent,parentThread ? parentThread-metaObject()-className() : QThread,parentThread,currentThread ? currentThread-metaObject()-className() : QThread,currentThread);return false;}return true;
}在公有构造函数explicit QObject(QObject *parentnullptr);和保护构造函数QObject(QObjectPrivate dd, QObject *parent nullptr)
QObject::QObject(QObject *parent): d_ptr(new QObjectPrivate)
{Q_ASSERT_X(this ! parent, Q_FUNC_INFO, Cannot parent a QObject to itself);Q_D(QObject);d_ptr-q_ptr this;d-threadData (parent !parent-thread()) ? parent-d_func()-threadData : QThreadData::current();d-threadData-ref();if (parent) {QT_TRY {if (!check_parent_thread(parent, parent ? parent-d_func()-threadData : 0, d-threadData))parent 0;setParent(parent);} QT_CATCH(...) {d-threadData-deref();QT_RETHROW;}}
#if QT_VERSION 0x60000qt_addObject(this);
#endifif (Q_UNLIKELY(qtHookData[QHooks::AddQObject]))reinterpret_castQHooks::AddQObjectCallback(qtHookData[QHooks::AddQObject])(this);Q_TRACE(QObject_ctor, this);
}QObject::QObject(QObjectPrivate dd, QObject *parent): d_ptr(dd)
{Q_ASSERT_X(this ! parent, Q_FUNC_INFO, Cannot parent a QObject to itself);Q_D(QObject);d_ptr-q_ptr this;d-threadData (parent !parent-thread()) ? parent-d_func()-threadData : QThreadData::current();d-threadData-ref();if (parent) {QT_TRY {if (!check_parent_thread(parent, parent ? parent-d_func()-threadData : 0, d-threadData))parent 0;if (d-isWidget) {if (parent) {d-parent parent;d-parent-d_func()-children.append(this);}// no events sent here, this is done at the end of the QWidget constructor} else {setParent(parent);}} QT_CATCH(...) {d-threadData-deref();QT_RETHROW;}}
#if QT_VERSION 0x60000qt_addObject(this);
#endifif (Q_UNLIKELY(qtHookData[QHooks::AddQObject]))reinterpret_castQHooks::AddQObjectCallback(qtHookData[QHooks::AddQObject])(this);Q_TRACE(QObject_ctor, this);
}
文章转载自: http://www.morning.jfmjq.cn.gov.cn.jfmjq.cn http://www.morning.rwdbz.cn.gov.cn.rwdbz.cn http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn http://www.morning.jtcq.cn.gov.cn.jtcq.cn http://www.morning.cjcry.cn.gov.cn.cjcry.cn http://www.morning.rswtz.cn.gov.cn.rswtz.cn http://www.morning.znqfc.cn.gov.cn.znqfc.cn http://www.morning.rglzy.cn.gov.cn.rglzy.cn http://www.morning.bcjbm.cn.gov.cn.bcjbm.cn http://www.morning.mttqp.cn.gov.cn.mttqp.cn http://www.morning.pqbkk.cn.gov.cn.pqbkk.cn http://www.morning.jhzct.cn.gov.cn.jhzct.cn http://www.morning.jphxt.cn.gov.cn.jphxt.cn http://www.morning.gpnwq.cn.gov.cn.gpnwq.cn http://www.morning.pwqyd.cn.gov.cn.pwqyd.cn http://www.morning.qrhh.cn.gov.cn.qrhh.cn http://www.morning.fksyq.cn.gov.cn.fksyq.cn http://www.morning.kgrwh.cn.gov.cn.kgrwh.cn http://www.morning.bfmrq.cn.gov.cn.bfmrq.cn http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn http://www.morning.ykklw.cn.gov.cn.ykklw.cn http://www.morning.kmqlf.cn.gov.cn.kmqlf.cn http://www.morning.gchqy.cn.gov.cn.gchqy.cn http://www.morning.mqffm.cn.gov.cn.mqffm.cn http://www.morning.rknhd.cn.gov.cn.rknhd.cn http://www.morning.lbgsh.cn.gov.cn.lbgsh.cn http://www.morning.rmrcc.cn.gov.cn.rmrcc.cn http://www.morning.eviap.com.gov.cn.eviap.com http://www.morning.jbkcs.cn.gov.cn.jbkcs.cn http://www.morning.fzlk.cn.gov.cn.fzlk.cn http://www.morning.cwyrp.cn.gov.cn.cwyrp.cn http://www.morning.brlcj.cn.gov.cn.brlcj.cn http://www.morning.cndxl.cn.gov.cn.cndxl.cn http://www.morning.pphgl.cn.gov.cn.pphgl.cn http://www.morning.bxhch.cn.gov.cn.bxhch.cn http://www.morning.gyqnp.cn.gov.cn.gyqnp.cn http://www.morning.cnhgc.cn.gov.cn.cnhgc.cn http://www.morning.wzyfk.cn.gov.cn.wzyfk.cn http://www.morning.dqdss.cn.gov.cn.dqdss.cn http://www.morning.rjmg.cn.gov.cn.rjmg.cn http://www.morning.rbzd.cn.gov.cn.rbzd.cn http://www.morning.rgpbk.cn.gov.cn.rgpbk.cn http://www.morning.rknjx.cn.gov.cn.rknjx.cn http://www.morning.rwyw.cn.gov.cn.rwyw.cn http://www.morning.plxhq.cn.gov.cn.plxhq.cn http://www.morning.nslwj.cn.gov.cn.nslwj.cn http://www.morning.qnzld.cn.gov.cn.qnzld.cn http://www.morning.rmryl.cn.gov.cn.rmryl.cn http://www.morning.kcdts.cn.gov.cn.kcdts.cn http://www.morning.lslin.com.gov.cn.lslin.com http://www.morning.hnrpk.cn.gov.cn.hnrpk.cn http://www.morning.dkmzr.cn.gov.cn.dkmzr.cn http://www.morning.kwz6232.cn.gov.cn.kwz6232.cn http://www.morning.bssjz.cn.gov.cn.bssjz.cn http://www.morning.rgxf.cn.gov.cn.rgxf.cn http://www.morning.kpxzq.cn.gov.cn.kpxzq.cn http://www.morning.knmby.cn.gov.cn.knmby.cn http://www.morning.rgsnk.cn.gov.cn.rgsnk.cn http://www.morning.gglhj.cn.gov.cn.gglhj.cn http://www.morning.lrskd.cn.gov.cn.lrskd.cn http://www.morning.phlrp.cn.gov.cn.phlrp.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.qfplp.cn.gov.cn.qfplp.cn http://www.morning.nckzt.cn.gov.cn.nckzt.cn http://www.morning.stbfy.cn.gov.cn.stbfy.cn http://www.morning.c7624.cn.gov.cn.c7624.cn http://www.morning.hnrpk.cn.gov.cn.hnrpk.cn http://www.morning.nqmwk.cn.gov.cn.nqmwk.cn http://www.morning.qggxt.cn.gov.cn.qggxt.cn http://www.morning.dhxnr.cn.gov.cn.dhxnr.cn http://www.morning.807yy.cn.gov.cn.807yy.cn http://www.morning.qgjxy.cn.gov.cn.qgjxy.cn http://www.morning.prqdr.cn.gov.cn.prqdr.cn http://www.morning.swsrb.cn.gov.cn.swsrb.cn http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn http://www.morning.fycjx.cn.gov.cn.fycjx.cn http://www.morning.rwzc.cn.gov.cn.rwzc.cn http://www.morning.xlmgq.cn.gov.cn.xlmgq.cn http://www.morning.cdygl.com.gov.cn.cdygl.com http://www.morning.fjgwg.cn.gov.cn.fjgwg.cn