[SOLVED] QRectF crashes the GUI upon exiting
-
It is running on windows 7. I think it is indeed memory corruption as the problem is no longer there after I clean and rebuild it. I will keep this in mind Asperacama. Thanks.
-
I realized that the problem happens whenever I add a new variable (NOT a pointer variable) in .h file. So I believe it is memory issue as mentioned earlier. Is there way to solve it? At time being I am overcoming this problem by rebuilding the project.
-
May be change the order of variables you declare inside class and see how it goes.
-
This sounds like your compiler somehow does not get the required dependency information, and does not recompile all files that use this changed header file.
Is this a single project, or are you working with libraries?
-
Yea it's not memory corruption. It is the compiler not picking up the header changes, thus forcing a rebuild to pick them up.
Make sure you have the header files defined in your *.pro file.
I.e.
@
HEADERS +=
myheader.h
anotherheader.hSOURCES +=
myheader.cpp
anotherheader.cpp
@Without that HEADERS line it will seem to compile properly but won't actually pick up header changes and can cause some really weird issues (at least with gcc).
-
The header files are already included. asperamanca yes I am working with qwt library.
-
Can you post your .pro file? Also what is your compiler? Are you using an IDE (msvc/qt creator/etc)?
-
Attached below is my .pro file. I am currently using Qt Creator 5.3.
@
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = gui
TEMPLATE = appHEADERS += widget.h
data.h
graph.h
barchart.h
udp.h
gauge.h
gauge2.hSOURCES += main.cpp
widget.cpp
data.cpp
graph.cpp
barchart.cpp
udp.cpp
gauge.cpp
gauge2.cppFORMS += widget.ui
QT += multimedia
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../Qwt-6.1.0/lib/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../Qwt-6.1.0/lib/ -lqwtdINCLUDEPATH += $$PWD/../../../../../../Qwt-6.1.0/include
DEPENDPATH += $$PWD/../../../../../../Qwt-6.1.0/include
@ -
Is your compiler mingw or msvc? I'm going to guess msvc cause your pro file looks good with the headers so mingw shouldn't be having the missing .h file checks that is causing your problem.
If it is msvc I'll have to let someone else help you. I don't really use it anymore, I think I have one legacy project that still uses it over mingw, but I haven't put any time into it since like 2000. So I just don't have the knowledge of it's idiosyncrasies.
-
I am using MinGW 4.8.2 compiler.
-
Hmm, if it's mingw this is definitely odd behavior indeed.
Maybe try running qmake to make sure that your project.pro.user file is up to date.
If it were me I would take it down to the command line and cut out the ide. Then use:
@
$ qmake
$ make
@And then once the build is complete, modify that header file (add a variable or whatever), touch the corresponding cpp file and make again. If it picks it up then it should be fine, there may be an issue with your ide at that point.
I don't know what else it could be it's a weird problem.
-
I did as you said. And at the time the problem is not there after I add a variable and make changes in the corresponding .cpp file.
I hope that really solves it.
Thanks ambershark.
-
No problem. I'm guessing you may have just needed to run a qmake. You probably added the header to the pro file and Qt Creator never re-ran qmake thus it didn't realize things had changed.
Just a guess without seeing it, but I'm pretty sure that's what happened if the qmake/make worked for you. :)
-
I see. Yes, I actually never re-run the qmake every time after I add a new header file. I didn't know that I have to.
Thank you ambershark
-
Yea I got in the habit of making sure I qmake all the time. I do it a lot even when I don't need to. Nothing more annoying than searching out a compiler issue because you didn't qmake. :)
Anyway, that being said, just make sure you do it after any changes to your pro file. If you are using Qt Creator I thought this was supposed to be automatic. I'm not sure though I tend to use SlickEdit or just vim for editing and build via qmake/make on the command line or in slickedit. So I always need to run qmake manually.
-
I think even in QT Creator we need to manually run the qmake. Have a look at this "thread":http://qt-project.org/forums/viewthread/40352.
Anyway thank you for the reply. By running the qmake everytime after adding a .h file, the problem is no longer there.