Segmentation fault in QApplication constractor
-
Hi guys!
I get very strange segmentation fault in my Qt desctop GUI app.
It is look like QApplication search execute file path and crash in this process, in Application constractor.
I found, that this error depend with length of path to my execute. For example in folder /home/user/Projects/Qt/myProgram/Developmet
it crash, but in folder /home/user launch normal.
Needed to say, that other my projects dnt have this problem.
I cant find reason of this error.
Can someone halp me with this trouble?I use solaris cpp compiler with solaris studio in my Solaris OS, static build of Qt application.
Qt version 4.6.1stack call of my program before crash:
qAtomicAssignQFileInfoPrivate::Data(0x1, 0x8ea97d8, 0x26, 0x89ddd2c)
QFileInfo::operator=(0x8045f54, 0x8045f24, 0x8045f40, 0x89ddd62)
QFileInfo::setFile(0x8045f54, 0x8045f70, 0x0, 0x1)
QFSFileEnginePrivate::canonicalized(0x8045ffc, 0x8046000, 0x3, 0x8a1b3c1)
QFSFileEngine::fileName(0x804649c, 0x8ea83c0, 0x6, 0x89dd22e)
QFileInfoPrivate::getFileName(0x804655c, 0x8ea83d0, 0x6, 0x89ddf84)
QFileInfo::canonicalFilePath(0x804655c, 0x8046558, 0x8046578, 0x8a36f4d)
QCoreApplication::applicationFilePath(0x80465ac, 0x8b29c98, 0x80465c8, 0x8a36d8e)
QCoreApplication::applicationDirPath(0x80465f4, 0xf, 0x2f2387f, 0x896fc1e)
QLibraryInfoPrivate::findConfiguration(0xfd3c3000, 0x8046620, 0x8046620, 0x8b29c98, 0x1, 0x8046430)
QLibrarySettings::QLibrarySettings(0x8ea83b0, 0x0, 0x4000, 0x896fad6)
qt_library_settings(0xfd3c3000, 0xfef1d81c, 0x1, 0x8046690, 0x1, 0x80464a0)
QLibraryInfo::location(0x80467e4, 0x5, 0x8046828, 0x8a37b93)
QCoreApplication::libraryPaths(0x804684c)
QCoreApplication::init(0x8046a9c, 0x8ea7490, 0x0, 0x8a34b46)
QCoreApplication::QCoreApplication(0x8046a9c, 0x8ea7490, 0x8046ad4, 0x1)
QApplication::QApplication(0x8046a9c, 0x8046ab0, 0x8046ad4, 0x40601, 0x0, 0x0)
main(argc = 1, argv = 0x8046ad4)main code:
#include <QtGui/QApplication>
#include "MainWindow.h" //main window header
#include <QTextCodec>
#include "definitions.h"* //file with VERSION and COMPILED constants*
#include <iostream>int main(int argc, char *argv[]) {
#ifdef COMPILED
std::cerr<<"Compiled date and time: "<<COMPILED<<"\n";
#endif
#ifdef VERSION
std::cerr<<"Current veriosn: "<<VERSION<<"\n";
#endif
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QApplication app(argc, argv); //Failed here all rows before works correct in other projects
MainWindow Form1;
Form1.show();
return app.exec();
} -
Hi and welcome to devnet,
I don't have any solaris system nor an old Qt version like that but from your code you're calling setCodecForTr and setCodecForCStrings too early. You need to first create the QApplication.
-
@SGaist thanks for your help. I chnaged my code, but this dnt help. I also use my exceptions in my project and multiple inheritance for one my class. My class inherits from simple class and QAbstractTableModel, and in header file of my class i declare
class MyClass: public QAbstractTableModel, public SimpleClass
{
}May be reason is wrong generated code?
-
What is SimpleClass ?
-
Does the crash also happen if you only have:
QApplication app(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); return app.exec();
in your main ?
-
@SGaist yes, I'm sory, needed to send you my main code earlier.
Look at my main code:
#include <QtGui/QApplication>
#include "MainWindow.h"
#include <QTextCodec>
#include "definitions.h"
#include <iostream>int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
#ifdef COMPILED
std::cerr<<"Compiled date and time: "<<COMPILED<<"\n";
#endif
#ifdef VERSION
std::cerr<<"Current veriosn: "<<VERSION<<"\n";
#endif
QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
MainWindow Form1;
Form1.show();
return app.exec();
} -
Again: before trying to analyze the results of your compiler, can you run a default application ?
-
If you want to use the solaris compiler with Qt you probably have to first recompile Qt yourself. Anyway, switching to g++ is not a bad idea in this case.