Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error : The inferior stopped because it received a signal from the operating system. Signal name : SIGABRT Signal meaning : Aborted
Forum Updated to NodeBB v4.3 + New Features

Error : The inferior stopped because it received a signal from the operating system. Signal name : SIGABRT Signal meaning : Aborted

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 312 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    a_h_s_
    wrote on last edited by
    #1

    Trying to build a very simple app that saves typed text into a database.

    The app crashes after connecting to database with the popup (while debugging, the app doesnt give any reason debug information otherwise).

    The inferior stopped because it received a signal from the operating system.  
    Signal name :  SIGABRT 
    Signal meaning :  Aborted
    

    Trial3.h

    #ifndef TRIAL03_H
    #define TRIAL03_H
    
    #include <QMainWindow>
    #include <QtSql>
    #include <QMessageBox>
    #include <iomanip>
    #include <iostream>
    
    QT_BEGIN_NAMESPACE
    namespace Ui {
    class Trial03;
    }
    QT_END_NAMESPACE
    
    class Trial03 : public QMainWindow
    {
        Q_OBJECT
    
    public:
        Trial03(QWidget *parent = nullptr);
        ~Trial03();
    
    private slots:
        void submit1();
    
    private:
        Ui::Trial03 *ui;
       QSqlDatabase dbCon;
    };
    #endif // TRIAL03_H
    

    Trial3.cpp

    #include "trial03.h"
    #include "ui_trial03.h"
    
    Trial03::Trial03(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::Trial03)
    {
        ui->setupUi(this);
        dbCon = QSqlDatabase::addDatabase("QSQLITE");
        dbCon.setDatabaseName("/T03.db");
        try{
            dbCon.open();
            //QMessageBox::information(this, "Activated", "Connected");
            throw(dbCon.lastError());
        }
        catch(QString err){
            QMessageBox::warning(this, "Error", err);
            qDebug() <<dbCon.lastError();
        }
    
    
    }
    
    Trial03::~Trial03()
    {
        delete ui;
    }
    
    void Trial03::submit1()
    {
        try{
            dbCon.open();
            throw(dbCon.lastError());
        }
        catch(QString err1){
            QMessageBox::warning(this, "Error", err1);
            qDebug() <<dbCon.lastError();
        }
        try{
            QSqlDatabase::database().transaction();
            QSqlQuery query(dbCon);
            query.prepare("INSERT INTO d1 (data) VALUES (:data)");
            query.bindValue(":data",ui->submit1->text());
            query.exec();
            QSqlDatabase::database().commit();
            throw(dbCon.lastError());
        }
        catch(QString err2){
            QMessageBox::warning(this, "Error", err2);
            qDebug() <<dbCon.lastError();
        }
        dbCon.close();
    }
    

    have enabled

    qt += sql
    

    have tried using std::cout to get the runtime error via terminal, doesnt work.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      First thing: Qt does not use exceptions so you either need to adapt your code or follow the guide that shows how you may make use of them. My recommendation, drop the exception in that piece of code.

      Next: why are you throwing everywhere in your code without doing a proper check of the return values of the method you use ?

      Finally: don't store QDatabase objects, the class documentation explains why.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved