qgraphicsitem.cpp中的Q_ASSERT(item-> d_ptr-> scene)

时间:2014-04-24 08:25:09

标签: c++ qt assert qgraphicsitem

当我删除两个图形项目时,我得到一个断言。 例如,我有一个使用以下代码继承QUndoCommand的类:

void CCommandCreationItem::undo () {
    m_pSynop->removeItem(m_pItem);
}


void CCommandCreationItem::redo() {
    m_pSynop->addItem(m_pItem);
}

我正在使用QUndoView来可视化堆栈。 所以我创建了两个项目,我有一个像这样的堆栈:

Initial state
Create (1) 
Create (2) <-

当我撤消创建(2)然后创建(1)时,它可以工作。

undo()                    undo()
--------------            -----------------
Initial state             Initial state <-
Create (1) <-             Create (1)
Create (2)                Create (2)

但是当我在Create(2)上并且我只是继续“初始状态”(我想它会执行两个undo()但比我更快)它会崩溃并出现以下断言:

Q_ASSERT(item->d_ptr->scene) in qgraphicsitem.cpp

我正在使用qt4.7.3。

看起来,它正在尝试绘制一个没有附加场景的项目。 [编辑]

我做错了吗?

调用堆栈:

>   QtCored4.dll!qt_message_output(QtMsgType msgType=QtFatalMsg, const char * buf=0x073f8118)  Line 2270    C++
    QtCored4.dll!qt_message(QtMsgType msgType=QtFatalMsg, const char * msg=0x672aa0d8, char * ap=0x002f9980)  Line 2328 + 0x12 bytes    C++
    QtCored4.dll!qFatal(const char * msg=0x672aa0d8, ...)  Line 2511 + 0xf bytes    C++
    QtCored4.dll!qt_assert(const char * assertion=0x65ad6934, const char * file=0x65ad6914, int line=11230)  Line 2027 + 0x16 bytes C++
    QtGuid4.dll!QGraphicsItemEffectSourcePrivate::draw(QPainter * painter=0x002fa41c)  Line 11230 + 0x29 bytes  C++
    QtGuid4.dll!QGraphicsEffectSource::draw(QPainter * painter=0x002fa41c)  Line 236    C++
    QtGuid4.dll!QGraphicsEffect::drawSource(QPainter * painter=0x002fa41c)  Line 254    C++
    QtGuid4.dll!QGraphicsColorizeEffect::draw(QPainter * painter=0x002fa41c)  Line 692  C++
    QtGuid4.dll!QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem * item=0x06d55ec0, QPainter * painter=0x002fa41c, const QTransform * const viewTransform=0x00000000, QRegion * exposedRegion=0x06d31e98, QWidget * widget=0x06c68a38, double parentOpacity=1.0000000000000000, const QTransform * const effectTransform=0x00000000)  Line 4847    C++
    QtGuid4.dll!QGraphicsScenePrivate::drawItems(QPainter * painter=0x002fa41c, const QTransform * const viewTransform=0x00000000, QRegion * exposedRegion=0x06d31e98, QWidget * widget=0x06c68a38)  Line 4735 + 0x34 bytes C++
    QtGuid4.dll!QGraphicsView::paintEvent(QPaintEvent * event=0x002fad5c)  Line 3470    C++
    QtGuid4.dll!QWidget::event(QEvent * event=0x002fad5c)  Line 8406    C++
    QtGuid4.dll!QFrame::event(QEvent * e=0x002fad5c)  Line 557 + 0xc bytes  C++
    QtGuid4.dll!QAbstractScrollArea::viewportEvent(QEvent * e=0x002fad5c)  Line 1043 + 0xc bytes    C++
    QtGuid4.dll!QGraphicsView::viewportEvent(QEvent * event=0x002fad5c)  Line 2865  C++
    QtGuid4.dll!QAbstractScrollAreaPrivate::viewportEvent(QEvent * event=0x002fad5c)  Line 100 + 0x28 bytes C++
    QtGuid4.dll!QAbstractScrollAreaFilter::eventFilter(QObject * o=0x06c68a38, QEvent * e=0x002fad5c)  Line 116 + 0x29 bytes    C++
    QtCored4.dll!QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject * receiver=0x06c68a38, QEvent * event=0x002fad5c)  Line 846 + 0x15 bytes    C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver=0x06c68a38, QEvent * e=0x002fad5c)  Line 4458 + 0x11 bytes    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver=0x06c68a38, QEvent * e=0x002fad5c)  Line 4427 + 0x10 bytes  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver=0x06c68a38, QEvent * event=0x002fad5c)  Line 731 + 0x15 bytes  C++
    QtCored4.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver=0x06c68a38, QEvent * event=0x002fad5c)  Line 218 + 0x38 bytes    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5492 + 0xe bytes  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=0, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=2, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=0, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=1, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=0, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=43, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5700   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=45, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=46, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=48, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=49, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=50, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::paintSiblingsRecursive(QPaintDevice * pdev=0x05a19fa8, const QList<QObject *> & siblings={...}, int index=51, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=4, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5687   C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x05a19fa8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=5, QPainter * sharedPainter=0x00000000, QWidgetBackingStore * backingStore=0x059b5b80)  Line 5547  C++
    QtGuid4.dll!QWidgetBackingStore::sync()  Line 1336  C++
    QtGuid4.dll!QWidgetPrivate::syncBackingStore()  Line 1845   C++
    QtGuid4.dll!QWidget::event(QEvent * event=0x073e3b28)  Line 8553    C++
    QtGuid4.dll!QMainWindow::event(QEvent * event=0x073e3b28)  Line 1481    C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver=0x002ffa30, QEvent * e=0x073e3b28)  Line 4462 + 0x11 bytes    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver=0x002ffa30, QEvent * e=0x073e3b28)  Line 4427 + 0x10 bytes  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver=0x002ffa30, QEvent * event=0x073e3b28)  Line 731 + 0x15 bytes  C++
    QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver=0x002ffa30, QEvent * event=0x073e3b28)  Line 215 + 0x39 bytes   C++
    QtCored4.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver=0x002ffa30, int event_type=77, QThreadData * data=0x00df3300)  Line 1372 + 0xd bytes  C++
    QtCored4.dll!QCoreApplication::sendPostedEvents(QObject * receiver=0x002ffa30, int event_type=77)  Line 1265 + 0x11 bytes   C++
    QtGuid4.dll!QGraphicsViewPrivate::dispatchPendingUpdateRequests()  Line 189 + 0x17 bytes    C++
    QtGuid4.dll!QGraphicsScenePrivate::_q_processDirtyItems()  Line 510 + 0x20 bytes    C++
    QtGuid4.dll!QGraphicsScene::qt_metacall(QMetaObject::Call _c=InvokeMetaMethod, int _id=14, void * * _a=0x00e265f0)  Line 130 + 0x12 bytes   C++
    EditeurSynop.exe!CSynoptiqueEditeur::qt_metacall(QMetaObject::Call _c=InvokeMetaMethod, int _id=18, void * * _a=0x00e265f0)  Line 88 + 0x17 bytes   C++
    QtCored4.dll!QMetaObject::metacall(QObject * object=0x05ab0860, QMetaObject::Call cl=InvokeMetaMethod, int idx=18, void * * argv=0x00e265f0)  Line 238  C++
    QtCored4.dll!QMetaCallEvent::placeMetaCall(QObject * object=0x05ab0860)  Line 535 + 0x19 bytes  C++
    QtCored4.dll!QObject::event(QEvent * e=0x073d8070)  Line 1217 + 0x14 bytes  C++
    QtGuid4.dll!QGraphicsScene::event(QEvent * event=0x073d8070)  Line 3544 + 0x10 bytes    C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver=0x05ab0860, QEvent * e=0x073d8070)  Line 4462 + 0x11 bytes    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver=0x05ab0860, QEvent * e=0x073d8070)  Line 3862 + 0x10 bytes  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver=0x05ab0860, QEvent * event=0x073d8070)  Line 731 + 0x15 bytes  C++
    QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver=0x05ab0860, QEvent * event=0x073d8070)  Line 215 + 0x39 bytes   C++
    QtCored4.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver=0x00000000, int event_type=0, QThreadData * data=0x00df3300)  Line 1372 + 0xd bytes   C++
    QtCored4.dll!qt_internal_proc(HWND__ * hwnd=0x003f0a28, unsigned int message=1025, unsigned int wp=0, long lp=0)  Line 497 + 0x10 bytes C++

刚添加了一条痕迹

void CCommandCreationItem::undo () {
    m_pSynop->removeItem(m_pItem);
    qDebug() << "@ITEM : " << reinterpret_cast<int*>(m_pItem);
}

@ITEM :  0x71b5e40 
@ITEM :  0x6a65018 
ASSERT: "item->d_ptr->scene" in file graphicsview\qgraphicsitem.cpp, line 11230

视觉:http://i.stack.imgur.com/grhWw.png

编辑:看来这个断言只是出现在我有一个精确的配置但我无法弄清楚哪一个......

你知道这个断言在哪些情况下会出现吗?

0 个答案:

没有答案