Solved Problem with disassembler and SIGILL signal
-
@kshegunov
If I don't declare it there where could I do it ? As said before that's not a code that I did myself and I don't really understand the way that it works (how the "path" is used thorugh the different pages ... -
@Amaury said in Problem with disassembler and SIGILL signal:
If I don't declare it there where could I do it
From the looks of it you can safely put the
db
initialization in main (after you've created the application object). As for the string, it's okay to leave it as a global. -
I tried like that but that doesn't work got a qualified-id in declaration before '(' token error
static const QString path = "localhost"; int main(int argc, char *argv[]) { QApplication a(argc, argv); DataBase MemTampon::Db(path); . . . }
Even with the string inside the main ...
-
It should be:
DataBase Db(path);
You're not initializing a static anymore.
-
The problem is if I don't use a static I can't do the calls for my other functions in my Database class..
const QString path = "localhost"; int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTranslator *qtTranslator = new QTranslator; qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); a.installTranslator(qtTranslator); DataBase Db(path); DataBase::Db.aff_Temperature(); DataBase::Db.aff_Humidite(); DataBase::Db.aff_Puissance(); DataBase::Db.aff_Nom_SD(); MainWindow w; w.show(); return a.exec(); }
(By the way I've delete the MemTampon that I agree was useless ... )
EDIT : My bad I'm dumb I think ^^ for the main it's alright just had to cut out the "DataBase::"
But I'm doing reference to the "Db" inside another page but the call doesn't work...
if (Db.isOpen()) { Temp = Db.aff_Temperature(); Humid = Db.aff_Humidite(); Puiss = Db.aff_Puissance(); Nom = Db.aff_Nom_SD(); Axe_X = Db.aff_AxeX(); Axe_Y = Db.aff_AxeY(); Axe_Z = Db.aff_AxeZ();
-
@Amaury said in Problem with disassembler and SIGILL signal:
if I don't use a static I can't do the calls for my other functions in my Database class..
Why not, you can always get the opened database (it's default named) by calling
QSqlDatabase db = QSqlDatabase::database()
. TheQSqlDatabase
class already keeps track of the opened connections for you. -
So what you mean is that for now my function
Database Db(path)
is just to specify if the connection is opened or not ? -
@Amaury
Eh, yes I suppose you could say that, currently in the constructor of your object you open the database:db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); // ...
so it serves as database initialization. You can do that in
main()
too, but that's another point. After the constructor's run, you can get the opened database the way I mentioned in my previous post. In principle it's not really needed to have a "database manager" with Qt, because theQSqlDatabase
class already keeps track of the connections, as mentioned. You can look up the two functionsQSqlDatabase::addDatabase
andQSqlDatabase::database
in the docs and I think it'll become clear from the examples there. -
Alright I'm going to check and change some things to see if that deletes the Sigill signal (hope so) I come back to give you feedback.
Thanks !
-
Hi there ,
I'm back again for some feedback , I changed the way I use my Database, I'm still connecting the same way, But all my functions that were in my class get swith into the only page that need those instructions .
That Way I Just connect through my databse page and just make a Signal Slot use when I need it.That said , my problem isn't solve for now I though maybe it was the Databse but seems not , maybe it's my refresh timer for my UI that creates crashes , anyway I'm still triying to find the problem..
If anyone could give me a clue for Valgrind to work , it's crashing a few seconds after starting the analysis and I just have the message that I post earlier.
That's a big post thank's for help and if I can't get in touch happy Christmas holidays.