confused about QFileDialog in debug and release mode
I want to get file names in the function void QQTScene::dropEvent(QGraphicsSceneDragDropEvent *event),QQTScene is a class inherited from QGraphicsScene .Within the function,I write
fileName = QFileDialog::getOpenFileName(NULL, tr("打开图片"), "",tr("Image Files (*.png *.jpg *.bmp)"));
to get a file name.
However,this works perfectly in release mode,while in debug mode it crashes saying that the memory can't be "read".
What is wrong?Thanks!
Re: confused about QFileDialog in debug and release mode
You're accessing some invalid pointer?
Where exacly does it crash, before getting the name, after, in getOpenFileName().
Use debugger to pin-point offending line.
Re: confused about QFileDialog in debug and release mode
Now if I just declare a QFileDialog variable in the function dropEvent() (just add one sentence),it will crash.If not adding this,it works perfectly.What's more,even in the release mode,it also craches after I just set the icon size of the toolbar.Is that strange?
Re: confused about QFileDialog in debug and release mode
I don't know.
Can you paste some actual code, it's difficult to spot any problems when just working with my imagination.
Re: confused about QFileDialog in debug and release mode
Code:
void QQTScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
const QMimeData *mimeData
= event
->mimeData
();
if(text == tr("文本"))
{
item = new QQTText(text);
}
else if(text == tr("图åƒ"))
{
fileName
= QFileDialog::getOpenFileName(0, tr
("打开图片"),
"",
tr("Image Files (*.png *.jpg *.bmp)"));
if(!fileName.isEmpty()){
item = new QQTImage(pixmap);
QRectF r
= item
->boundingRect
();
if(r.width() > 800)
{
item->scale(0.5, 0.5);
}
//connect(qgraphicsitem_cast<QQTImage *>(item), SIGNAL(resize()), this, SLOT(resize()));
/* 修改当å‰å·¥ä½œç›®å½•,使下次打开图片的时候å¯ä»¥å‡å°‘釿–°é€‰æ‹©ç›®å½•çš„æ“作 */
}
else
{
event->setDropAction(Qt::IgnoreAction);
return;
}
}
item->setPos(event->scenePos());
addItem(item);
event->setDropAction(Qt::CopyAction);
event->accept();
}
It crashes at
Code:
fileName
= QFileDialog::getOpenFileName(0, tr
("打开图片"),
"",
tr("Image Files (*.png *.jpg *.bmp)"));
I debug it to find that it crashes in system function
Code:
void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
int w, int h,
int const_alpha)
at line
Code:
BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, w, nullVector, half, one, colorMask, alphaMask);