Qt 5.0.1 c++ customContextMenuRequested on empty QListWidget give First chance access violation



  • evry strange i build simple customContextMenu that operates on QListWidget
    but when i do right click on empty QListWidget or on empty area on the QListWidget im getting :
    First chance access violation after few seconds , not right away ..

    here is my simple code :
    Mainwindow.cpp

    @ pListWidgetItemDelegate = new ListWidgetItemDelegate(ui->listWidget);
    ui->listWidget->setItemDelegate(pListWidgetItemDelegate);
    ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->listWidget->setAutoScroll(false);

    connect(ui->listWidget,
       SIGNAL(customContextMenuRequested(QPoint)),
       this,
       SLOT(showContextMenu(QPoint)));
    
        void MainWindow::showContextMenu(QPoint point)
        { 
            QMenu menu;
            QPoint vpPos = ui->listWidget->viewport()->mapFromGlobal(point);
         QListWidgetItem* item = ui->listWidget->itemAt(point);
         if(item)
         {
          
           menu.addAction(tr("&Copy link"))->setData("link");
          menu.addAction(tr("&Download video"))->setData("download");
          if(dd->downloadState == DownloadData::Progressing)
          {
           menu.addAction(tr("&Cancel"))->setData("cancel");
           menu.addSeparator();
           menu.addAction(tr("&Remove from list"))->setData("remove");
          }
          else if(dd->downloadState == DownloadData::Canceled || dd->downloadState == DownloadData::Error )
          {
           menu.addAction(tr("&Retry"))->setData("retry");
           menu.addSeparator();
           menu.addAction(tr("Remove from &list"))->setData("remove");
          }
          else if(dd->downloadState == DownloadData::Completed)
          { 
           menu.addAction(tr("&Open folder"))->setData("folder");
           menu.addSeparator();
           menu.addAction(tr("&Delete"))->setData("delete");
           menu.addAction(tr("Remove from &list"))->setData("remove");
        
          }
          else if(dd->downloadState == DownloadData::Start)
          {
           menu.addSeparator();
           menu.addAction(tr("&Delete"))->setData("delete");
           menu.addAction(tr("Remove from &list"))->setData("remove");
        
          }
             
         
          QAction* action;// = menu.exec(ui->listWidget->viewport()->mapToGlobal(point));
          // If statement is workaround for QTBUG-6256
          if (point != QPoint(0,0)) {
           // Execute context menu
           action =  menu.exec(ui->listWidget->viewport()->mapToGlobal(point));
          }
          if(!action) 
          {
           return;
          }
           if(action->data().toString() == "download")
          {
           if(!recordItem(item))
            return;
          }
           
        
        
           if(dd->downloadState == DownloadData::Progressing)
           {
            
            if(action)
            {
             if(action->data().toString() == "cancel")
             {
              cancelDownload(item);
             }
             else if(action->data().toString() == "remove")
             {
              itemsMarkedForRemoval.append(item);
              cancelDownload(item);
             }
            }
             }
             else if(dd->downloadState == DownloadData::Canceled || dd->downloadState == DownloadData::Error )
           {
                   
            if(action)
            {
             if(action->data().toString() == "retry")
             {
              retryDownload(item);
             }
             else if(action->data().toString() == ("remove"))
             {
              delete item->data(DownloadDataRole).value<DownloadData*>();
               
             }
            }
        
           }
           else if(dd->downloadState == DownloadData::Completed)
           {
                     
                   
            if(action)
            {
             if(action->data().toString() == "folder")
             {
              openFolder();
             }
             else if(action->data().toString() == "delete")
             {
              
             }
             else if(action->data().toString() == "remove")
             {
              
             }
            }
        
           }
           else if(dd->downloadState == DownloadData::Start)
           {
                     
                     
                   
            if(action)
            {
                         
             if(action->data().toString() == "delete")
             {
              
             }
             else if(action->data().toString() == "remove")
             {
              
             }
            }
        
           }
          }
        
          
        }
    

    @

    now when i check with the microsoft Application Verifier

    im getting this stack :

    @ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    ...
    ...

       <avrf:trace>Qt5Cored!QTimer::isSingleShot+29eebb ( @ 0)</avrf:trace>
        <avrf:trace>Qt5Guid!QTransform::fromTranslate+569c1 ( @ 0)</avrf:trace>
        <avrf:trace>Qt5Widgetsd!QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent+30e42 ( @ 0)</avrf:trace>
        <avrf:trace>YouTubeLocal!main+271 (d:\dev\svn_client\trunk\youtubelocal\youtubelocal\main.cpp @ 71)</avrf:trace>
        <avrf:trace>YouTubeLocal!WinMain+7a (q:\qt5_workdir\w\s\qtbase\src\winmain\qtmain_win.cpp @ 131)</avrf:trace>
        <avrf:trace>YouTubeLocal!__tmainCRTStartup+260 (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 547)</avrf:trace>
        <avrf:trace>YouTubeLocal!WinMainCRTStartup+f (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 371)</avrf:trace>
        
    </avrf:logfile>@

Log in to reply
 

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