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
Code:
void MainWindow::getFilename()
{
msgbox.setText("Please select the file");
filepath
= QFileDialog::getOpenFileName(this, tr
("Open File"),
"/home",tr
("Text files(*.txt)"));
if(filepath.isEmpty())
msgbox.exec();
}
I would be grateful for any solution.
Thank You,
Baluk
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)
Re: Application stops working unexpectedly
oke. I run the app in debug mode and I receive a message that
Quote:
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.
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.
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.
Re: Application stops working unexpectedly
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.
Re: Application stops working unexpectedly
Quote:
Originally Posted by
baluk
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.
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.
Re: Application stops working unexpectedly
Go back in the trace to the first line you can see which is from your code.
Re: Application stops working unexpectedly
From my code I get the error next after the destructor statement . When I press F10 from the statement, I get the segmentation fault message.
Re: Application stops working unexpectedly
you probably forgot to do ui = new <YourUIWidget>;
Re: Application stops working unexpectedly
Post the whole backtrace.
1 Attachment(s)
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
Quote:
Lowest section in C:\Windows\system32\normaliz.dll is .text at 00401000
in the console after stopping the debugger.
Re: Application stops working unexpectedly
So the crash happens when you are closing the application? Does the program work correctly until then?
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.
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.