Results 1 to 5 of 5

Thread: Exit Code 3

  1. #1
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Exit Code 3

    Not sure if it's right board but it concerns Qt so... I got this code:
    Qt Code:
    1. // main.h
    2.  
    3. #include "ui.h"
    4.  
    5. class Main {
    6. public:
    7. Main()
    8. {
    9. }
    10.  
    11. void init() {
    12. ui.show();
    13. }
    14. private:
    15. UI ui;
    16. };
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. // main. cpp
    2.  
    3. #include "main.h"
    4. #include <QtGui/QApplication>
    5.  
    6. Main g_main;
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication a(argc, argv);
    11.  
    12. g_main.init();
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    And the problem is that creating g_main as a global variable gives me this:
    URL removed

    With some console errors:
    Qt Code:
    1. Invalid parameter passed to C runtime function.
    2. Invalid parameter passed to C runtime function.
    3. Exited with code 3
    To copy to clipboard, switch view to plain text mode 

    When I put Main g_main as a local variable into main() function then everything works fine. Moreover, in another project (without Qt) I have no such problem.

    I'm using Qt 4.7.0 with MingW.
    Last edited by wysota; 10th March 2011 at 23:54. Reason: removed URL

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Exit Code 3

    What is UI? It looks like a widget so it can't be global because you need a QApplication instance to be able to instantiate widgets. You should even get a warning about this at run time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Exit Code 3

    UI is my main window (inherits QWidget) and the only warning I get is "Invalid parameter passed to C runtime function.".

    Anyway, the problem disappeared after declaring ui on heap and initializing it with the new keyword.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Exit Code 3

    Quote Originally Posted by RSX View Post
    UI is my main window (inherits QWidget) and the only warning I get is "Invalid parameter passed to C runtime function.".
    This is an error not a warning. The warning goes to the console that you can't see without a development environment.

    Anyway, the problem disappeared after declaring ui on heap and initializing it with the new keyword.
    ...after QApplication is initalized.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Exit Code 3

    Quote Originally Posted by wysota View Post
    This is an error not a warning. The warning goes to the console that you can't see without a development environment.
    I'm using Qt IDE so I should receive it there anyway.

    Quote Originally Posted by wysota View Post
    ...after QApplication is initalized.
    Yes, in the init() function which is ... exactly what you said.

Similar Threads

  1. cannot exit from fullscreen
    By lazycoder in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2011, 06:38
  2. Is there a guide for exit code messages?
    By tonnot in forum Newbie
    Replies: 13
    Last Post: 9th December 2010, 10:45
  3. What means the "error n. 3" exit code?
    By glafauci in forum Qt Programming
    Replies: 0
    Last Post: 27th November 2010, 15:44
  4. Replies: 2
    Last Post: 21st November 2010, 18:03
  5. clean exit!!
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2008, 16:33

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.