PDA

View Full Version : Debug Assertion Failed



beethoven07
21st February 2013, 14:25
help to resolve this ....

8748

#include "dialog.h"
#include "ui_dialog.h"
#define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"

Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
myDB = QSqlDatabase::addDatabase ("QSQLITE");
myDB.setDatabaseName (path_to_db);
QFileInfo checkFile (path_to_db);

if(checkFile.isFile())
{
if(myDB.open())
{
ui->lblStatus->setText("berhasil konek database");
}

}else
{
ui->lblStatus->setText("nda ta konek di database :(");
}

}

Dialog::~Dialog()
{
delete ui;
qDebug()<< "keluar dari database pada waktu program di matikan";
myDB.close();
}

void Dialog::on_btnClear_clicked()
{
ui->txtPassword->setText("");
ui->txtUsername->setText("");

}

void Dialog::on_btnLogin_clicked()
{
QString username, password;
username = ui->txtUsername->text();
password = ui->txtPassword->text();

if(!myDB.isOpen()) {
qDebug() << "No connection to DB :(";
return;
}
QSqlQuery qry;
if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
"\' AND password=\'" + password + "\'"))
{
if(qry.next())
{
ui->lblStatus ->setText("username dan password benar");
QString msg = "username = " +qry.value(0).toString() + "\n" +
"password = " +qry.value(1).toString() + "\n" +
"role = " +qry.value(2).toString();
QMessageBox::warning(this, "Login berhasil", msg);

} else {
ui->lblStatus->setText("Sala Password atau username bego");
}
}
}

do i did something mistake with this code?
thanks....

amleto
21st February 2013, 19:28
Yes, you made a mistake somewhere. Maybe not in that little bit of code, though. Read my sig - you should seek to provide a *complete* example.

If your code is crashing then it would be useful to provide a stack trace and indicate in your code where the relevant lines are.

Have you used your debugger yet? What have you found so faR?

beethoven07
21st February 2013, 23:42
when I build in debug mode everything is fine... but when in release mode this error coming up...

btw in application output i found this...

Starting C:\Users\beethoven07\Documents\QT programming\loginform-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\loginform.exe...
The program has unexpectedly finished.
C:\Users\beethoven07\Documents\QT programming\loginform-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\loginform.exe exited with code 62097
this my complete code...

loginform.pro

#-------------------------------------------------
#
# Project created by QtCreator 2013-02-21T10:56:20
#
#-------------------------------------------------
QT += core gui sql


greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = loginform
TEMPLATE = app


SOURCES += main.cpp\
dialog.cpp

HEADERS += dialog.h

FORMS += dialog.ui


dialog.h

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QDebug>
#include <QtSql>
#include <QMessageBox>
#include <QFileInfo>



namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
Q_OBJECT

public:
explicit Dialog(QWidget *parent = 0);
~Dialog();

private slots:
void on_btnClear_clicked();

void on_btnLogin_clicked();

private:
Ui::Dialog *ui;
QSqlDatabase myDB;
};

#endif // DIALOG_H


dialog.cpp

#include "dialog.h"
#include "ui_dialog.h"
#define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"

Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
myDB = QSqlDatabase::addDatabase ("QSQLITE");
myDB.setDatabaseName (path_to_db);
QFileInfo checkFile (path_to_db);

if(checkFile.isFile())
{
if(myDB.open())
{
ui->lblStatus->setText("berhasil konek database");
}

}else
{
ui->lblStatus->setText("nda ta konek di database :(");
}

}

Dialog::~Dialog()
{
delete ui;
qDebug()<< "keluar dari database pada waktu program di matikan";
myDB.close();
}

void Dialog::on_btnClear_clicked()
{
ui->txtPassword->setText("");
ui->txtUsername->setText("");

}

void Dialog::on_btnLogin_clicked()
{
QString username, password;
username = ui->txtUsername->text();
password = ui->txtPassword->text();

if(!myDB.isOpen()) {
qDebug() << "No connection to DB :(";
return;
}
QSqlQuery qry;
if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
"\' AND password=\'" + password + "\'"))
{
if(qry.next())
{
ui->lblStatus ->setText("username dan password benar");
QString msg = "username = " +qry.value(0).toString() + "\n" +
"password = " +qry.value(1).toString() + "\n" +
"role = " +qry.value(2).toString();
QMessageBox::warning(this, "Login berhasil", msg);

} else {
ui->lblStatus->setText("Sala Password atau username bego");
}
}
}



main.cpp

#include "dialog.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();

return a.exec();
}


thx....

amleto
22nd February 2013, 00:17
Please attach debugger when you get the crash and show the stack trace. You should double check your usages of pointers - you are probably using an initialized one.

beethoven07
22nd February 2013, 00:50
by the way how to set up the debbuger, when i want to debbug, ive this message No Debbuger Setup.... Im so newbie for using QT, btw im sorry for my bad English.... currently im using QT 5 and visual studio 2010.....

ChrisW67
22nd February 2013, 05:39
and visual studio 2010.....
I am sure that somewhere in the help for Microsoft's Visual Studio product (http://msdn.microsoft.com/en-us/library/vstudio/sc65sadd%28v=vs.100%29.aspx) it tells you how to configure the Microsoft debugger in the Microsoft IDE.

beethoven07
22nd February 2013, 06:20
I am sure that somewhere in the help for Microsoft's Visual Studio product (http://msdn.microsoft.com/en-us/library/vstudio/sc65sadd%28v=vs.100%29.aspx) it tells you how to configure the Microsoft debugger in the Microsoft IDE.

thank you mate... i will chek it up....

amleto
22nd February 2013, 21:53
" ive this message No Debbuger Setup"

Where does that message come from?

beethoven07
23rd February 2013, 00:01
" ive this message No Debbuger Setup"

Where does that message come from?

the message comes from here...
8758

btw im stuck till now... please help me...

amleto
23rd February 2013, 01:41
That's not visual studio, is it!? That's qt creator.

Firstly, did you compile qt with Microsoft compiler or mingw compiler? If the former, then please google qt creator Microsoft debugging.

beethoven07
23rd February 2013, 10:10
Yes... it is QT creator... how can I debug in QT creator with vs2010, to trace where if i do something wrong with the code or something else.... ive download QT 5 with vs2010 not minGW...

amleto
23rd February 2013, 13:19
That's not visual studio, is it!? That's qt creator.

Firstly, did you compile qt with Microsoft compiler or mingw compiler? If the former, then please google qt creator Microsoft debugging.


Yes... it is QT creator... how can I debug in QT creator with vs2010, to trace where if i do something wrong with the code or something else.... ive download QT 5 with vs2010 not minGW...


That's not visual studio, is it!? That's qt creator.

Firstly, did you compile qt with Microsoft compiler or mingw compiler? If the former, then please google qt creator Microsoft debugging.
Please read more carefully.

beethoven07
23rd February 2013, 14:06
this the error maybe this can help:

8759

8760

the full traced code here:
8761

amleto
23rd February 2013, 17:09
the problem isn't microsoft code, so there is no benefit to be gained from you showing us microsoft source code. show us YOUR CODE where the error happens.

Show a *call stack* AKA *stack trace*. Google it if you don't know what that is.

the problem isn't microsoft code, so there is no benefit to be gained from you showing us microsoft source code. show us YOUR CODE where the error happens.

Show a *call stack* AKA *stack trace*. Google it if you don't know what that is.

Added after 9 minutes:

8762
That is a call stack.