Results 1 to 14 of 14

Thread: Debug Assertion Failed

  1. #1
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Debug Assertion Failed

    help to resolve this ....

    Untitled.jpg
    Qt Code:
    1. #include "dialog.h"
    2. #include "ui_dialog.h"
    3. #define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"
    4.  
    5. Dialog::Dialog(QWidget *parent) :
    6. QDialog(parent),
    7. ui(new Ui::Dialog)
    8. {
    9. ui->setupUi(this);
    10. myDB = QSqlDatabase::addDatabase ("QSQLITE");
    11. myDB.setDatabaseName (path_to_db);
    12. QFileInfo checkFile (path_to_db);
    13.  
    14. if(checkFile.isFile())
    15. {
    16. if(myDB.open())
    17. {
    18. ui->lblStatus->setText("berhasil konek database");
    19. }
    20.  
    21. }else
    22. {
    23. ui->lblStatus->setText("nda ta konek di database :(");
    24. }
    25.  
    26. }
    27.  
    28. Dialog::~Dialog()
    29. {
    30. delete ui;
    31. qDebug()<< "keluar dari database pada waktu program di matikan";
    32. myDB.close();
    33. }
    34.  
    35. void Dialog::on_btnClear_clicked()
    36. {
    37. ui->txtPassword->setText("");
    38. ui->txtUsername->setText("");
    39.  
    40. }
    41.  
    42. void Dialog::on_btnLogin_clicked()
    43. {
    44. QString username, password;
    45. username = ui->txtUsername->text();
    46. password = ui->txtPassword->text();
    47.  
    48. if(!myDB.isOpen()) {
    49. qDebug() << "No connection to DB :(";
    50. return;
    51. }
    52. QSqlQuery qry;
    53. if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
    54. "\' AND password=\'" + password + "\'"))
    55. {
    56. if(qry.next())
    57. {
    58. ui->lblStatus ->setText("username dan password benar");
    59. QString msg = "username = " +qry.value(0).toString() + "\n" +
    60. "password = " +qry.value(1).toString() + "\n" +
    61. "role = " +qry.value(2).toString();
    62. QMessageBox::warning(this, "Login berhasil", msg);
    63.  
    64. } else {
    65. ui->lblStatus->setText("Sala Password atau username bego");
    66. }
    67. }
    68. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. The following user says thank you to amleto for this useful post:

    beethoven07 (21st February 2013)

  4. #3
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-02-21T10:56:20
    4. #
    5. #-------------------------------------------------
    6. QT += core gui sql
    7.  
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = loginform
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. dialog.cpp
    17.  
    18. HEADERS += dialog.h
    19.  
    20. FORMS += dialog.ui
    To copy to clipboard, switch view to plain text mode 

    dialog.h
    Qt Code:
    1. #ifndef DIALOG_H
    2. #define DIALOG_H
    3.  
    4. #include <QDialog>
    5. #include <QDebug>
    6. #include <QtSql>
    7. #include <QMessageBox>
    8. #include <QFileInfo>
    9.  
    10.  
    11.  
    12. namespace Ui {
    13. class Dialog;
    14. }
    15.  
    16. class Dialog : public QDialog
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. explicit Dialog(QWidget *parent = 0);
    22. ~Dialog();
    23.  
    24. private slots:
    25. void on_btnClear_clicked();
    26.  
    27. void on_btnLogin_clicked();
    28.  
    29. private:
    30. Ui::Dialog *ui;
    31. };
    32.  
    33. #endif // DIALOG_H
    To copy to clipboard, switch view to plain text mode 

    dialog.cpp
    Qt Code:
    1. #include "dialog.h"
    2. #include "ui_dialog.h"
    3. #define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"
    4.  
    5. Dialog::Dialog(QWidget *parent) :
    6. QDialog(parent),
    7. ui(new Ui::Dialog)
    8. {
    9. ui->setupUi(this);
    10. myDB = QSqlDatabase::addDatabase ("QSQLITE");
    11. myDB.setDatabaseName (path_to_db);
    12. QFileInfo checkFile (path_to_db);
    13.  
    14. if(checkFile.isFile())
    15. {
    16. if(myDB.open())
    17. {
    18. ui->lblStatus->setText("berhasil konek database");
    19. }
    20.  
    21. }else
    22. {
    23. ui->lblStatus->setText("nda ta konek di database :(");
    24. }
    25.  
    26. }
    27.  
    28. Dialog::~Dialog()
    29. {
    30. delete ui;
    31. qDebug()<< "keluar dari database pada waktu program di matikan";
    32. myDB.close();
    33. }
    34.  
    35. void Dialog::on_btnClear_clicked()
    36. {
    37. ui->txtPassword->setText("");
    38. ui->txtUsername->setText("");
    39.  
    40. }
    41.  
    42. void Dialog::on_btnLogin_clicked()
    43. {
    44. QString username, password;
    45. username = ui->txtUsername->text();
    46. password = ui->txtPassword->text();
    47.  
    48. if(!myDB.isOpen()) {
    49. qDebug() << "No connection to DB :(";
    50. return;
    51. }
    52. QSqlQuery qry;
    53. if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
    54. "\' AND password=\'" + password + "\'"))
    55. {
    56. if(qry.next())
    57. {
    58. ui->lblStatus ->setText("username dan password benar");
    59. QString msg = "username = " +qry.value(0).toString() + "\n" +
    60. "password = " +qry.value(1).toString() + "\n" +
    61. "role = " +qry.value(2).toString();
    62. QMessageBox::warning(this, "Login berhasil", msg);
    63.  
    64. } else {
    65. ui->lblStatus->setText("Sala Password atau username bego");
    66. }
    67. }
    68. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include "dialog.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Dialog w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    thx....
    Attached Files Attached Files
    Last edited by beethoven07; 22nd February 2013 at 00:26.

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. #5
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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.....
    Last edited by beethoven07; 22nd February 2013 at 01:14.

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Debug Assertion Failed

    and visual studio 2010.....
    I am sure that somewhere in the help for Microsoft's Visual Studio product it tells you how to configure the Microsoft debugger in the Microsoft IDE.

  8. The following user says thank you to ChrisW67 for this useful post:

    beethoven07 (22nd February 2013)

  9. #7
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    Quote Originally Posted by ChrisW67 View Post
    I am sure that somewhere in the help for Microsoft's Visual Studio product it tells you how to configure the Microsoft debugger in the Microsoft IDE.
    thank you mate... i will chek it up....

  10. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    " ive this message No Debbuger Setup"

    Where does that message come from?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  11. The following user says thank you to amleto for this useful post:

    beethoven07 (23rd February 2013)

  12. #9
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    Quote Originally Posted by amleto View Post
    " ive this message No Debbuger Setup"

    Where does that message come from?
    the message comes from here...
    error.jpg

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

  13. #10
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  14. #11
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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...

  15. #12
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    Quote Originally Posted by amleto View Post
    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.
    Quote Originally Posted by beethoven07 View Post
    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...
    Quote Originally Posted by amleto View Post
    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.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  16. #13
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    this the error maybe this can help:

    error 2222.jpg

    error local heap.jpg

    the full traced code here:
    debugfull.zip

  17. #14
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Debug Assertion Failed

    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:


    Capture.jpg
    That is a call stack.
    Last edited by amleto; 23rd February 2013 at 17:09.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Qt OpenGL: Assertion Failed When Close the Window
    By Seishin in forum Qt Programming
    Replies: 5
    Last Post: 21st August 2012, 15:18
  2. Replies: 2
    Last Post: 17th December 2010, 08:26
  3. "Debug Assertion failed" in debug mode
    By hed in forum Qt Programming
    Replies: 10
    Last Post: 4th February 2008, 12:10
  4. Debug Assertion Failed
    By ^NyAw^ in forum General Programming
    Replies: 5
    Last Post: 28th December 2007, 11:48
  5. ASSERT(Failed assertion in Qt == Qt bug)
    By 0xBulbizarre in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 19:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.