ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343



  • I want to get the thumbnail from QGraphicsScene:
    @ QImage image;
    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing);
    scene->render(&painter);
    image.save("scene.png");@

    scene->render throw the error and error detail is:
    @---------------------------
    Microsoft Visual C++ Debug Library

    Debug Error!

    Program: ...\PBMaker\Source\Trunk\PBMaker\PBMaker\Win32\Debug\PBMaker.exe
    Module: 5.0.1
    File: global\qglobal.cpp
    Line: 1951

    ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343

    (Press Retry to debug the application)

    Abort Retry Ignore

    @

    and my scene is :
    @ QGraphicsScene *scene = new QGraphicsScene();
    scene->setBackgroundBrush(Qt::white);
    scene->addWidget(page);
    scene->setSceneRect(0,0,mSceneSize.width(),mSceneSize.height());

        //add all areas
        QList<PBArea *> areas =  page->getArea();  
        int areaTotalNumber = areas.size();
        for ( int areaIndex = 0 ; areaIndex < areaTotalNumber ; areaIndex++ )
        {       
            scene->addItem(areas[areaIndex]);
        }@
    

    page inherts from QWidget , PBArea inherts from QGraphicsItem.

    a little strange to get this debug error. am i missing something ?



  • and I test the scene->render again in a clear Qt project:
    @#include "qttest501.h"
    #include <QGraphicsScene>
    #include <QPainter>
    #include <QDesktopWidget>
    qtTest501::qtTest501(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);

    QGraphicsScene *scene = new QGraphicsScene();
    scene->addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));   
    
    QPixmap pixmap;
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    scene->render(&painter);
    painter.end();
    
    bool sceneRet =  pixmap.save("scene.png","png");
    
    pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(),pos().x(),pos().y(),frameGeometry().width(),frameGeometry().height());
    bool pixmapRet =  pixmap.save("blog.png","png");
    

    }

    qtTest501::~qtTest501()
    {

    }
    @
    and sceneRet is false and pixmapRet is true... also strange..



  • I modify
    @QPixmap pixmap;@
    to
    @QPixmap pixmap(130,130);@
    and sceneRet can return true and get the correct thunbnail.

    but for the ASSERT error still have even if i change
    @QImage image;@
    to
    @ QImage image(70,70,QImage::Format_ARGB32);@

    if i try to get the thumbnail from QGraphicsView, it success .

    STRANGE.



  • I know why the Debug error pop-up:
    my scene 's size is 100100, but one of my item is position is 200105. change it back into the scene's size. debug error disappear.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.