Hi,

I am trying to read contents from Windows Address Book using the following code.

Qt Code:
  1. #include <list>
  2. using namespace std;
  3.  
  4. WABImporter::WABImporter(ContactDetails *cd,QWidget *parent) : QDialog(parent),contactDetails(cd)
  5. {
  6. setAttribute(Qt::WA_DeleteOnClose);
  7. setWindowTitle(tr("Windows Address Book"));
  8.  
  9. cWAB = new CWAB("");//This object has no Qt code and is used to read from windows address book
  10.  
  11. contactData = new ContactData(this);
  12.  
  13. splitter = new QSplitter(Qt::Horizontal,this);
  14.  
  15. listWidget = new QListWidget(this);
  16.  
  17. viewMode = new ViewMode(this);
  18. cardArea = new QScrollArea(this);
  19. cardArea->setMinimumWidth(300);
  20. cardArea->setWidget(viewMode);
  21. cardArea->setWidgetResizable(true);
  22. cardArea->setFrameStyle(QFrame::Box|QFrame::Plain);
  23.  
  24. splitter->addWidget(listWidget);
  25. splitter->addWidget(cardArea);
  26.  
  27. importCurrentButton = new QPushButton(tr("&Import current contact"),this);
  28. importAllButton = new QPushButton(tr("&Import &All"),this);
  29. cancelButton = new QPushButton(tr("&Cancel"),this);
  30.  
  31. connect(importCurrentButton,SIGNAL(pressed()),this,SLOT(importCurrent()));
  32. connect(importAllButton,SIGNAL(pressed()),this,SLOT(importAll()));
  33. connect(cancelButton,SIGNAL(pressed()),this,SLOT(close()));
  34.  
  35. QHBoxLayout *hLay1 = new QHBoxLayout;
  36. hLay1->addStretch(1);
  37. hLay1->addWidget(importCurrentButton);
  38. hLay1->addWidget(importAllButton);
  39. hLay1->addWidget(cancelButton);
  40.  
  41. QVBoxLayout *mainLayout = new QVBoxLayout(this);
  42. mainLayout->addWidget(splitter);
  43. mainLayout->addLayout(hLay1);
  44.  
  45. setLayout(mainLayout);
  46. setMinimumSize(640,480);
  47.  
  48. populateContactsList();
  49. }
  50.  
  51. WABImporter::~WABImporter()
  52. {
  53. cWAB->ClearWABLVContents();
  54. delete cWAB;//This crashes the application
  55. }
  56.  
  57. void WABImporter::populateContactsList()
  58. {
  59. list<string> contactsList;
  60. if(cWAB->LoadWABContents(contactsList)){
  61. list<string>::iterator listIterator;
  62. for(listIterator = contactsList.begin(); listIterator != contactsList.end(); ++listIterator){
  63. listWidget->addItem(QString::fromStdString(*listIterator));
  64. }
  65. }
  66. }
To copy to clipboard, switch view to plain text mode 

There is a menu option, clicking on which will open a dialog box and all the windows contacts are listed there. When I close this dialog the application crahes in

qeventdispatcher_win.cpp

Qt Code:
  1. Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
  2. UINT wMsgFilterMax, UINT wRemoveMsg)
  3. {
  4. QT_WA({ return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); } ,
  5. { return PeekMessageA(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); });//Crashes here
  6. }
To copy to clipboard, switch view to plain text mode 

Another very strange thing is that it crahses only when I put a break point in the destructor i.e. delete cWAB and try to debug from there.

Otherwise, when I close the dialog, nothing happens but crashes when I close the main application window.

The main application window crahes in qwidget.cpp

Qt Code:
  1. void QWidgetPrivate::hide_helper()
  2. {
  3. Q_Q(QWidget);
  4. if ((q->windowType() == Qt::Popup))
  5. qApp->d_func()->closePopup(q);
  6.  
  7. // Move test modal here. Otherwise, a modal dialog could get
  8. // destroyed and we lose all access to its parent because we haven't
  9. // left modality. (Eg. modal Progress Dialog)
  10. if (q->isModal())
  11. QApplicationPrivate::leaveModal(q);
  12.  
  13. #if defined(Q_WS_WIN)
  14. if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
  15. && !q->parentWidget()->isHidden() && q->isActiveWindow())
  16. q->parentWidget()->activateWindow(); // Activate parent
  17. #endif
  18.  
  19. q->setAttribute(Qt::WA_Mapped, false);
  20. hide_sys();//CRASHES HERE
  21.  
  22. bool wasVisible = q->testAttribute(Qt::WA_WState_Visible);
  23.  
  24. if (wasVisible) {
  25. q->setAttribute(Qt::WA_WState_Visible, false);
  26.  
  27. }
To copy to clipboard, switch view to plain text mode 

Please Help!