Results 1 to 5 of 5

Thread: confused about QFileDialog in debug and release mode

  1. #1
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  5. #5
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: confused about QFileDialog in debug and release mode

    Qt Code:
    1. void QQTScene::dropEvent(QGraphicsSceneDragDropEvent *event)
    2. {
    3. const QMimeData *mimeData = event->mimeData();
    4. QString text = mimeData->text();
    5.  
    6.  
    7. if(text == tr("文本"))
    8. {
    9. item = new QQTText(text);
    10. connect(qgraphicsitem_cast<QQTText *>(item), SIGNAL(selectedChange(QGraphicsItem*)), this, SIGNAL(itemSelected(QGraphicsItem*)));
    11. }
    12. else if(text == tr("图像"))
    13. {
    14. QString fileName;
    15. fileName = QFileDialog::getOpenFileName(0, tr("打开图片"), "",
    16. tr("Image Files (*.png *.jpg *.bmp)"));
    17.  
    18. if(!fileName.isEmpty()){
    19. QPixmap pixmap(fileName);
    20. item = new QQTImage(pixmap);
    21. QRectF r = item->boundingRect();
    22. if(r.width() > 800)
    23. {
    24. item->scale(0.5, 0.5);
    25. }
    26. //connect(qgraphicsitem_cast<QQTImage *>(item), SIGNAL(resize()), this, SLOT(resize()));
    27. /* 修改当前工作目录,使下次打开图片的时候可以减少重新选择目录的操作 */
    28. QDir::setCurrent(QFileInfo(fileName).absolutePath());
    29. }
    30. else
    31. {
    32. event->setDropAction(Qt::IgnoreAction);
    33. return;
    34. }
    35. }
    36. item->setPos(event->scenePos());
    37. addItem(item);
    38.  
    39. event->setDropAction(Qt::CopyAction);
    40. event->accept();
    41. }
    To copy to clipboard, switch view to plain text mode 
    It crashes at
    Qt Code:
    1. fileName = QFileDialog::getOpenFileName(0, tr("打开图片"), "",
    2. tr("Image Files (*.png *.jpg *.bmp)"));
    To copy to clipboard, switch view to plain text mode 

    I debug it to find that it crashes in system function
    Qt Code:
    1. void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
    2. const uchar *srcPixels, int sbpl,
    3. int w, int h,
    4. int const_alpha)
    To copy to clipboard, switch view to plain text mode 
    at line
    Qt Code:
    1. BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, w, nullVector, half, one, colorMask, alphaMask);
    To copy to clipboard, switch view to plain text mode 
    Last edited by furskytl; 23rd December 2011 at 12:07.

Similar Threads

  1. Replies: 4
    Last Post: 27th May 2010, 16:18
  2. Debug or Release mode in MAC
    By ssaa in forum Installation and Deployment
    Replies: 6
    Last Post: 9th March 2010, 06:15
  3. Replies: 1
    Last Post: 2nd November 2009, 13:02
  4. Replies: 9
    Last Post: 15th April 2009, 07:23
  5. Replies: 8
    Last Post: 10th October 2007, 19:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.