munna
7th November 2006, 11:13
Hi,
I am trying to read contents from Windows Address Book using the following code.
#include <list>
using namespace std;
WABImporter::WABImporter(ContactDetails *cd,QWidget *parent) : QDialog(parent),contactDetails(cd)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("Windows Address Book"));
cWAB = new CWAB("");//This object has no Qt code and is used to read from windows address book
contactData = new ContactData(this);
splitter = new QSplitter(Qt::Horizontal,this);
listWidget = new QListWidget(this);
viewMode = new ViewMode(this);
cardArea = new QScrollArea(this);
cardArea->setMinimumWidth(300);
cardArea->setWidget(viewMode);
cardArea->setWidgetResizable(true);
cardArea->setFrameStyle(QFrame::Box|QFrame::Plain);
splitter->addWidget(listWidget);
splitter->addWidget(cardArea);
importCurrentButton = new QPushButton(tr("&Import current contact"),this);
importAllButton = new QPushButton(tr("&Import &All"),this);
cancelButton = new QPushButton(tr("&Cancel"),this);
connect(importCurrentButton,SIGNAL(pressed()),this ,SLOT(importCurrent()));
connect(importAllButton,SIGNAL(pressed()),this,SLO T(importAll()));
connect(cancelButton,SIGNAL(pressed()),this,SLOT(c lose()));
QHBoxLayout *hLay1 = new QHBoxLayout;
hLay1->addStretch(1);
hLay1->addWidget(importCurrentButton);
hLay1->addWidget(importAllButton);
hLay1->addWidget(cancelButton);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(splitter);
mainLayout->addLayout(hLay1);
setLayout(mainLayout);
setMinimumSize(640,480);
populateContactsList();
}
WABImporter::~WABImporter()
{
cWAB->ClearWABLVContents();
delete cWAB;//This crashes the application
}
void WABImporter::populateContactsList()
{
list<string> contactsList;
if(cWAB->LoadWABContents(contactsList)){
list<string>::iterator listIterator;
for(listIterator = contactsList.begin(); listIterator != contactsList.end(); ++listIterator){
listWidget->addItem(QString::fromStdString(*listIterator));
}
}
}
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
Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
UINT wMsgFilterMax, UINT wRemoveMsg)
{
QT_WA({ return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); } ,
{ return PeekMessageA(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); });//Crashes here
}
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
void QWidgetPrivate::hide_helper()
{
Q_Q(QWidget);
if ((q->windowType() == Qt::Popup))
qApp->d_func()->closePopup(q);
// Move test modal here. Otherwise, a modal dialog could get
// destroyed and we lose all access to its parent because we haven't
// left modality. (Eg. modal Progress Dialog)
if (q->isModal())
QApplicationPrivate::leaveModal(q);
#if defined(Q_WS_WIN)
if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
&& !q->parentWidget()->isHidden() && q->isActiveWindow())
q->parentWidget()->activateWindow(); // Activate parent
#endif
q->setAttribute(Qt::WA_Mapped, false);
hide_sys();//CRASHES HERE
bool wasVisible = q->testAttribute(Qt::WA_WState_Visible);
if (wasVisible) {
q->setAttribute(Qt::WA_WState_Visible, false);
}
Please Help!
I am trying to read contents from Windows Address Book using the following code.
#include <list>
using namespace std;
WABImporter::WABImporter(ContactDetails *cd,QWidget *parent) : QDialog(parent),contactDetails(cd)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("Windows Address Book"));
cWAB = new CWAB("");//This object has no Qt code and is used to read from windows address book
contactData = new ContactData(this);
splitter = new QSplitter(Qt::Horizontal,this);
listWidget = new QListWidget(this);
viewMode = new ViewMode(this);
cardArea = new QScrollArea(this);
cardArea->setMinimumWidth(300);
cardArea->setWidget(viewMode);
cardArea->setWidgetResizable(true);
cardArea->setFrameStyle(QFrame::Box|QFrame::Plain);
splitter->addWidget(listWidget);
splitter->addWidget(cardArea);
importCurrentButton = new QPushButton(tr("&Import current contact"),this);
importAllButton = new QPushButton(tr("&Import &All"),this);
cancelButton = new QPushButton(tr("&Cancel"),this);
connect(importCurrentButton,SIGNAL(pressed()),this ,SLOT(importCurrent()));
connect(importAllButton,SIGNAL(pressed()),this,SLO T(importAll()));
connect(cancelButton,SIGNAL(pressed()),this,SLOT(c lose()));
QHBoxLayout *hLay1 = new QHBoxLayout;
hLay1->addStretch(1);
hLay1->addWidget(importCurrentButton);
hLay1->addWidget(importAllButton);
hLay1->addWidget(cancelButton);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(splitter);
mainLayout->addLayout(hLay1);
setLayout(mainLayout);
setMinimumSize(640,480);
populateContactsList();
}
WABImporter::~WABImporter()
{
cWAB->ClearWABLVContents();
delete cWAB;//This crashes the application
}
void WABImporter::populateContactsList()
{
list<string> contactsList;
if(cWAB->LoadWABContents(contactsList)){
list<string>::iterator listIterator;
for(listIterator = contactsList.begin(); listIterator != contactsList.end(); ++listIterator){
listWidget->addItem(QString::fromStdString(*listIterator));
}
}
}
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
Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
UINT wMsgFilterMax, UINT wRemoveMsg)
{
QT_WA({ return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); } ,
{ return PeekMessageA(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); });//Crashes here
}
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
void QWidgetPrivate::hide_helper()
{
Q_Q(QWidget);
if ((q->windowType() == Qt::Popup))
qApp->d_func()->closePopup(q);
// Move test modal here. Otherwise, a modal dialog could get
// destroyed and we lose all access to its parent because we haven't
// left modality. (Eg. modal Progress Dialog)
if (q->isModal())
QApplicationPrivate::leaveModal(q);
#if defined(Q_WS_WIN)
if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
&& !q->parentWidget()->isHidden() && q->isActiveWindow())
q->parentWidget()->activateWindow(); // Activate parent
#endif
q->setAttribute(Qt::WA_Mapped, false);
hide_sys();//CRASHES HERE
bool wasVisible = q->testAttribute(Qt::WA_WState_Visible);
if (wasVisible) {
q->setAttribute(Qt::WA_WState_Visible, false);
}
Please Help!