[Interest] QSopedPointer crashes application at exit
Igor Mironchik
igor.mironchik at gmail.com
Thu Sep 19 11:36:11 CEST 2013
Hi.
I wrote simple test application that reproduse my problem.
The problem is in QScopedPointer at exit point
inline T *data() const
{
return d;
}
method.
Here is call stack:
Qt5Widgetsd.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
>::data() Line 132 C++
Qt5Widgetsd.dll!qGetPtrHelper<QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
> >(const QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData>
> & p) Line 886 C++
Qt5Widgetsd.dll!QApplication::d_func() Line 222 C++
Qt5Widgetsd.dll!QWidget::~QWidget() Line 1432 C++
Qt5Widgetsd.dll!QMainWindow::~QMainWindow() Line 379 C++
test.exe!MainWindow::~MainWindow() Line 36 C++
test.exe!`MainWindow::instance'::`2'::`dynamic atexit destructor
for 'inst''() C++
msvcr110d.dll!doexit(int code, int quick, int retcaller) Line 585 C
msvcr110d.dll!exit(int code) Line 395 C
test.exe!__tmainCRTStartup() Line 549 C
test.exe!mainCRTStartup() Line 377 C
kernel32.dll!76f9336a() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded
for kernel32.dll]
ntdll.dll!77d49f72() Unknown
ntdll.dll!77d49f45() Unknown
But why?
Here is the code:
#include <QApplication>
#include <QMainWindow>
#include <QWidget>
#include <QScopedPointer>
#include <QMenuBar>
#include <QMenu>
class MainWindowPrivate {
public:
MainWindowPrivate()
: m_widget( 0 )
{
}
QWidget * m_widget;
};
class MainWindow
: public QMainWindow
{
Q_OBJECT
private:
MainWindow( QWidget * parent = 0, Qt::WindowFlags f = 0 )
: QMainWindow( parent, f )
, d( new MainWindowPrivate )
{
init();
}
~MainWindow()
{
}
public:
static MainWindow & instance()
{
static MainWindow inst;
return inst;
}
private:
void init()
{
QMenu * fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( QIcon(),
tr( "E&xit" ), qApp, SLOT( quit() ),
QKeySequence( tr( "Ctrl+Q" ) ) );
d->m_widget = new QWidget( this );
setCentralWidget( d->m_widget );
}
private:
Q_DISABLE_COPY( MainWindow )
QScopedPointer< MainWindowPrivate > d;
};
int main( int argc, char ** argv )
{
QApplication app( argc, argv );
MainWindow::instance().show();
return app.exec();
}
#include "main.moc"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130919/686a7f01/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 1049 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130919/686a7f01/attachment.cpp>
More information about the Interest
mailing list