Results 1 to 17 of 17

Thread: Application stops working unexpectedly

  1. #1
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Application stops working unexpectedly

    Hi,

    in my app I am reading a file name by opening a QFileDialog and save the filename to a string variable. And then I check for the variable in question of filename returned. I am doing this with an If statement and showing message box if the variable is empty. But when I get to the If statement my program showing a message that "example.exe has stopped working unexpectedly". here is my code

    Qt Code:
    1. void MainWindow::getFilename()
    2. {
    3. QMessageBox msgbox;
    4. msgbox.setText("Please select the file");
    5. filepath = QFileDialog::getOpenFileName(this, tr("Open File"),"/home",tr("Text files(*.txt)"));
    6. if(filepath.isEmpty())
    7. msgbox.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    I would be grateful for any solution.

    Thank You,
    Baluk
    Last edited by baluk; 19th November 2010 at 10:20.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Application stops working unexpectedly

    run the application in a debugger, and see exactly where it crashes, you will probably also see why (NULL pointer or similar)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    oke. I run the app in debug mode and I receive a message that
    The inferior stopped because it received a signal from operating system, SignalName : SIGSEGV SiganMeaning:Sigmentation fault
    .
    I have removed the above function from my app and I still get this error when I try to close the app by clicking on the "Close" menu item on the top of the window. Can you tell me why is it because if it is a common error.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Application stops working unexpectedly

    No - run the app in the debugger - this means you run it from within the debugger - not by double clicking on the exe.
    The code you posted should not crash, the problem is somewhere else in your app.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    oke. But I run the program from the Qt creator not by clicking the exe file. Unfortunately I have no idea where to look for when debugger shows me some output when I get the error message.

  6. #6
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    can you post more code?

  7. #7
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    My app has 200 lines of code. I don't know from which portion the error is. But my program exited with code -1073741819.

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

    Default Re: Application stops working unexpectedly

    Quote Originally Posted by baluk View Post
    oke. I run the app in debug mode and I receive a message that
    .
    I have removed the above function from my app and I still get this error when I try to close the app by clicking on the "Close" menu item on the top of the window. Can you tell me why is it because if it is a common error.
    When you get this, Creator should show you where the crash occured. There should be a backtrace available so that you can see where it crashes. And forseeing your next question - no, we will not teach you here what backtrace is. If you are a programmer you should either already know that or be able to find it out yourself.
    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.


  9. #9
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    Yes I see the backtrace when I run in the debug mode. The applications crashes at QObjectPrivate::deleteChilderen() function in the qobject.cpp file at line 1978. Can you tell me what it means.

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Application stops working unexpectedly

    Go back in the trace to the first line you can see which is from your code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    From my code I get the error next after the destructor statement
    delete ui;
    . When I press F10 from the statement, I get the segmentation fault message.

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Application stops working unexpectedly

    you probably forgot to do ui = new <YourUIWidget>;
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    Default Re: Application stops working unexpectedly

    Post the whole backtrace.
    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.


  14. #14
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    Here I am attaching the image showing the debugger output. I can't see the option to copy the output. And I see the message
    Lowest section in C:\Windows\system32\normaliz.dll is .text at 00401000
    in the console after stopping the debugger.
    Attached Images Attached Images

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

    Default Re: Application stops working unexpectedly

    So the crash happens when you are closing the application? Does the program work correctly until then?
    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.


  16. #16
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application stops working unexpectedly

    yes exactly. the crash happens only when closing the app. Until then every thing works fine. Before It was running fine but when I added the above function my app started crashing. So I then removed the function but still the crash happens when closing the application.

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

    Default Re: Application stops working unexpectedly

    My guess is that you have a double delete somewhere. You are deleting some object explicitly and then MainWindow destructor deletes it again.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 7th November 2012, 23:28
  2. Program has unexpectedly finished
    By Maluko_Da_Tola in forum Newbie
    Replies: 5
    Last Post: 1st December 2010, 10:54
  3. Thread stops after a while in release mode
    By huba in forum Qt Programming
    Replies: 4
    Last Post: 21st July 2010, 05:29
  4. Replies: 2
    Last Post: 14th July 2009, 15:25
  5. tab stops ?
    By ixM in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2009, 14:11

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.