Results 1 to 10 of 10

Thread: Qwizard crashed when created in a slot

  1. #1
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Qwizard crashed when created in a slot

    I'm trying to use the QWizard class introduced in Qt4.3.0 but whenever I try to create my QWizard derived class in a slot, I get an access violation deep in the Qt library:

    qwizard_win.cpp
    Qt Code:
    1. bool QVistaHelper::handleWinEvent(MSG *message, long *result)
    2. {
    3. bool status = false;
    4. if (wizard->wizardStyle() == QWizard::AeroStyle) {
    5. status = winEvent(message, result);
    6. if (message->message == WM_NCCALCSIZE) {
    7. if (status)
    8. collapseTopFrameStrut();
    9. } else if (message->message == WM_NCPAINT) {
    10. wizard->update();
    11. }
    12. }
    13. return status;
    14. }
    To copy to clipboard, switch view to plain text mode 

    It appears as if the wizard pointer is no longer valid. Here is my calling code:

    Qt Code:
    1. void MyApp::testSlot()
    2. {
    3. NewProjectWizard* projwizard = new NewProjectWizard( this );
    4. projwizard->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

    This code works fine anywhere but in a connected slot. Has anyone else experienced this? Could someone else test this and see if I'm crazy? I have Qt 4.3.0 compiled for Microsft Visual Studio 2005 installed and I'm running Windows XP, not Vista. Maybe Qt4.3.1 fixes this problem but I didn't see anything in the change log. Any help would be appreciated, thanks.
    Last edited by jpn; 15th January 2008 at 11:25. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qwizard crashed when created in a slot

    Quote Originally Posted by joshlareau View Post
    Could someone else test this and see if I'm crazy?
    Could you prepare a minimal compilable example that reproduces the problem so we can test it?
    J-P Nurmi

  3. #3
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qwizard crashed when created in a slot

    It looks like it's not just with any connected slot, but only slots connected to widgets on a toolbar or to QActions signals.

    Here is the minimally compilable source code that will recreate the problem:

    Qt Code:
    1. //main.cpp
    2. #include <QtGui/QApplication>
    3. #include "example.h"
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. example w;
    8. w.show();
    9. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //example.h
    2. #include <QtGui/QMainWindow>
    3. #include <QAction>
    4. #include <QToolBar>
    5. class example: public QMainWindow
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. example( QWidget *parent = 0, Qt::WFlags flags = 0 );
    11.  
    12. public slots:
    13. void TestSlot();
    14.  
    15. private:
    16. QToolBar *mainToolBar;
    17. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //Example.cpp
    2. #include "example.h"
    3. #include <QWizard>
    4. #include <QToolButton>
    5. example::example(QWidget *parent, Qt::WFlags flags)
    6. : QMainWindow(parent, flags)
    7. {
    8. mainToolBar = new QToolBar( this );
    9.  
    10. QToolButton* tstButton = new QToolButton;
    11. tstButton->setText( "Test" );
    12. mainToolBar->addWidget( tstButton );
    13.  
    14. connect( tstButton, SIGNAL( clicked() ), this, SLOT( TestSlot() ) );
    15. }
    16.  
    17. void example::TestSlot()
    18. {
    19. QWizard* myWizard = new QWizard( this );
    20. myWizard->show();
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 15th January 2008 at 11:27. Reason: missing [code] tags

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qwizard crashed when created in a slot

    Hmm, for me it runs fine with WinXP / MSVC 2005 / Qt 4.3.0. Could you copy and paste contents of call stack by the time it crashes?
    J-P Nurmi

  5. #5
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qwizard crashed when created in a slot

    Here is the call stack. I've attached my source files too if that helps.

    mincompex.exe!QVistaHelper::handleWinEvent(tagMSG * message=0x0012b38c, long * result=0x0012b3b0) Line 374 + 0x3 bytes C++
    mincompex.exe!QWizard::winEvent(tagMSG * message=0x0012b38c, long * result=0x0012b3b0) Line 2820 C++
    mincompex.exe!QtWndProc(HWND__ * hwnd=0x00020784, unsigned int message=128, unsigned int wParam=0, long lParam=0) Line 1366 + 0x18 bytes C++
    user32.dll!7e418734()
    [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
    user32.dll!7e418816()
    user32.dll!7e41b89b()
    user32.dll!7e42f3cc()
    mincompex.exe!QWidgetPrivate::setWindowIcon_sys(bo ol forceReset=false) Line 774 C++
    mincompex.exe!QWidget::create(HWND__ * window=0x00000000, bool initializeWindow=true, bool destroyOldWindow=true) Line 1107 C++
    mincompex.exe!QWidgetPrivate::createWinId(HWND__ * winid=0x00000000) Line 1826 C++
    mincompex.exe!QWidgetPrivate::createWinId(HWND__ * winid=0x00000000) Line 1809 C++
    mincompex.exe!QWidgetPrivate::createWinId(HWND__ * winid=0x00000000) Line 1809 C++
    mincompex.exe!QWidget::winId() Line 1794 C++
    mincompex.exe!QAccessible::updateAccessibility(QOb ject * o=0x016986e8, int who=0, QAccessible::Event reason=NameChanged) Line 161 + 0xe bytes C++
    mincompex.exe!QAbstractButton::setText(const QString & text={...}) Line 616 + 0x10 bytes C++
    mincompex.exe!QWizardPrivate::ensureButton(QWizard ::WizardButton which=BackButton) Line 1125 + 0x61 bytes C++
    mincompex.exe!QWizardPrivate::init() Line 585 C++
    mincompex.exe!QWizard::QWizard(QWidget * parent=0x0012fe9c, QFlags<enum Qt::WindowType> flags={...}) Line 1915 C++
    mincompex.exe!mincompex::TestSlot() Line 20 + 0x33 bytes C++
    mincompex.exe!mincompex::qt_metacall(QMetaObject:: Call _c=InvokeMetaMethod, int _id=0, void * * _a=0x0012be74) Line 66 C++
    mincompex.exe!QMetaObject::activate(QObject * sender=0x01634c88, int from_signal_index=29, int to_signal_index=30, void * * argv=0x0012be74) Line 3066 + 0x46 bytes C++
    mincompex.exe!QMetaObject::activate(QObject * sender=0x01634c88, const QMetaObject * m=0x00f9e0a4, int from_local_signal_index=2, int to_local_signal_index=3, void * * argv=0x0012be74) Line 3145 + 0x15 bytes C++
    mincompex.exe!QAbstractButton::clicked(bool _t1=false) Line 180 + 0x16 bytes C++
    mincompex.exe!QAbstractButtonPrivate::emitClicked( ) Line 519 C++
    mincompex.exe!QAbstractButtonPrivate::click() Line 511 C++
    mincompex.exe!QAbstractButton::mouseReleaseEvent(Q MouseEvent * e=0x0012c4b4) Line 1088 C++
    mincompex.exe!QToolButton::mouseReleaseEvent(QMous eEvent * e=0x0012c4b4) Line 644 C++
    mincompex.exe!QWidget::event(QEvent * event=0x0012c4b4) Line 6032 C++
    mincompex.exe!QAbstractButton::event(QEvent * e=0x0012c4b4) Line 1050 C++
    mincompex.exe!QToolButton::event(QEvent * e=0x0012c4b4) Line 1061 C++
    mincompex.exe!QApplicationPrivate::notify_helper(Q Object * receiver=0x01634c88, QEvent * e=0x0012c4b4) Line 3538 + 0x11 bytes C++
    mincompex.exe!QApplication::notify(QObject * receiver=0x01634c88, QEvent * e=0x0012c4b4) Line 3237 + 0x2f bytes C++
    mincompex.exe!QCoreApplication::notifyInternal(QOb ject * receiver=0x01634c88, QEvent * event=0x0012c4b4) Line 510 C++
    mincompex.exe!QCoreApplication::sendSpontaneousEve nt(QObject * receiver=0x01634c88, QEvent * event=0x0012c4b4) Line 189 + 0x38 bytes C++
    mincompex.exe!QETWidget::translateMouseEvent(const tagMSG & msg={...}) Line 2746 + 0x13 bytes C++
    mincompex.exe!QtWndProc(HWND__ * hwnd=0x00020786, unsigned int message=514, unsigned int wParam=0, long lParam=524314) Line 1378 + 0xc bytes C++
    user32.dll!7e418734()
    user32.dll!7e418816()
    user32.dll!7e4189cd()
    user32.dll!7e418a10()
    mincompex.exe!QEventDispatcherWin32:rocessEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 521 + 0x18 bytes C++
    ntdll.dll!7c96cd11()
    ntdll.dll!7c960af8()
    ntdll.dll!7c960bf0()
    ntdll.dll!7c960bcc()
    mincompex.exe!_free_base(void * pBlock=0x00000004) Line 109 + 0x12 bytes C
    mincompex.exe!_free_dbg(void * pUserData=0x00000000, int nBlockUse=22111800) Line 1225 + 0x7 bytes C++
    mincompex.exe!_free_dbg(void * pUserData=0x01694984, int nBlockUse=2090195884) Line 1222 + 0xc bytes C++
    ntdll.dll!7c95db5c()
    ntdll.dll!7c96cd11()
    ntdll.dll!7c960af8()
    ntdll.dll!7c960bf0()
    ntdll.dll!7c960bcc()
    mincompex.exe!QRegion::~QRegion() Line 200 + 0xb bytes C++
    mincompex.exe!QETWidget::translatePaintEvent(const tagMSG & msg={...}) Line 3087 + 0x13 bytes C++
    mincompex.exe!QtWndProc(HWND__ * hwnd=0x00000008, unsigned int message=0, unsigned int wParam=22085632, long lParam=22085632) Line 1668 + 0xc bytes C++
    ntdll.dll!7c96cd11()
    ntdll.dll!7c960af8()
    ntdll.dll!7c960bf0()
    ntdll.dll!7c9106eb()
    mincompex.exe!_heap_alloc_base(unsigned int size=17367936) Line 105 + 0x28 bytes C
    mincompex.exe!_unlock(int locknum=17367936) Line 376 C
    Attached Files Attached Files
    Last edited by jpn; 15th January 2008 at 11:28. Reason: missing [quote] tags

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qwizard crashed when created in a slot

    Did you compile Qt by hand? For some reason your wizard has QWizard::AeroStyle set, even if it should be only possible on Vista. I'm sure you can get past the problem by setting another wizard style by hand but I'm suspecting something might be wrong with your Qt installation.
    J-P Nurmi

  7. #7
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qwizard crashed when created in a slot

    I did compile Qt by hand. Was I supposed to specify windows XP somewhere during configure? I've tried explicitly setting the QWizard style but it didn't seem to fix it.

  8. #8
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qwizard crashed when created in a slot

    I think I may have found a workaround. In my slot I was doing the following:

    QWizard* myWizard = new QWizard( this );

    However, if I make myWizard a member of my class and I move that line outside the slot, say to the constructor of my class and then only call myWizard->show() in the slot, everything works fine.

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qwizard crashed when created in a slot

    Quote Originally Posted by joshlareau View Post
    I did compile Qt by hand. Was I supposed to specify windows XP somewhere during configure?
    It should be all detected just fine by default but configure output could have shown something suspicious.

    I've tried explicitly setting the QWizard style but it didn't seem to fix it.
    That's weird, because the crashing line (qwizard_win.cpp, 374) gets never executed if wizard style is something else than QWizard::AeroStyle. Does it crash somewhere else?
    J-P Nurmi

  10. #10
    Join Date
    Apr 2006
    Location
    Denmark / Norway
    Posts
    67
    Thanks
    3
    Thanked 12 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qwizard crashed when created in a slot

    I was just wondering if anyone found a solution to this one, as I seem to have the exact same issue right now...

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.