Fatal error 11 when close windows



  • Hello,

    I do a little project wth Qt 5.3.0 for Android. In random mode it closes with error Fatal error 11. It works correctly in Windows 8.

    I thinks who the problem is connect with Virtual keyboard of Android, after than I use Virtual keyboard when I push the bottom to exits, if there is a little delay it close with error Fatal error 11.

    I Saw the programs closes when there is a delay after than I use virtual keyboard.
    But this problem is random

    I use Sqlite with QDataWidget.

    What do you thinks?

    Thanks


  • Moderators

    Hi,

    Fatal error 11 is the segmentation fault error. Your code is trying to access some unitialized memory AFAIK.
    Can you post the code ?



  • Hello,

    I post the class, when it is closed I see the fatal error 11.

    The slot on_pushButton_ok_clicked() close the Window.

    @
    #include "gui/guireservation.h"
    #include "ui_guireservation.h"

    GuiReservation::GuiReservation(QWidget *parent, int iDReservation, int tableReservation_id, QString dateReservation) :
    QDialog(parent),
    ui(new Ui::GuiReservation)
    {
    ui->setupUi(this);
    move(QApplication::desktop()->screen()->rect().center() - rect().center());
    this->tableReservation_id = tableReservation_id;
    this->dateReservation = dateReservation;
    db.setDb(QSqlDatabase::database(PrgConst::conNameDB,true));
    this->idReservation = iDReservation;
    model = new QSqlRelationalTableModel(this, db.getDb());
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    qCDebug(QT_LOG_DB) << "BEGIN TRANSACTION " << model->database().transaction();

    loadTables();
    
    mapper = new QDataWidgetMapper(this);
    mapper->setModel(model);
    mapper->setItemDelegate(new QSqlRelationalDelegate(this));
    mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
    mapper->addMapping(ui->lineEdit_client, model->fieldIndex("name"));
    mapper->addMapping(ui->lineEdit_fromhour, model->fieldIndex("fromhour"));
    mapper->addMapping(ui->lineEdit_tohour, model->fieldIndex("tohour"));
    mapper->addMapping(ui->lineEdit_note, model->fieldIndex("note"));
    mapper->addMapping(ui->dateEdit,  model->fieldIndex("date"));
    
    mapper->toLast();
    qCDebug(QT_LOG_GUI) << "n. model row" << model->rowCount();
    qCDebug(QT_LOG_GUI) << "id Reseservation :" <<  model->index(model->rowCount()-1,0).data(Qt::DisplayRole).toInt();
    

    }

    GuiReservation::~GuiReservation()
    {
    delete ui;
    }

    void GuiReservation::updateButtons(int row)
    {
    Q_UNUSED(row);
    }

    void GuiReservation::enableGroupbox(const QModelIndex &index)
    {
    Q_UNUSED(index);
    }

    void GuiReservation::on_pushButton_ok_clicked()
    {
    saveCurrentRow();
    qCDebug(QT_LOG_DB) << "COMMIT TRANSACTION " << model->database().commit();
    QApplication::processEvents();
    this->hide();
    this->close();
    }

    void GuiReservation::loadIcone()
    {

    }

    void GuiReservation::loadTables()
    {
    model->setTable("reservation");
    typeIndexClient = model->fieldIndex("client_id");
    qCDebug(QT_LOG_DB) << typeIndexClient;
    model->setRelation(typeIndexClient, QSqlRelation("client", "id", "name"));

    //Common part I use only to get name of current table
    LocalTableMap local_table;
    db.getLocalTableByIdReservation(local_table, tableReservation_id);
    ui->lineEdit_table->setText(local_table.getDescription());
    
    
    qCDebug(QT_LOG_GUI) << "Reservation exists " << idReservation;
    //The reservation esists. reservation.id is primary key
    model->setFilter(QString(" reservation.id = %1").arg(QString::number(idReservation)));
    if(!model->select()) {  qCCritical(QT_LOG_DB) << model->lastError().text();return;  }
    qCDebug(QT_LOG_DB) << model->query().lastQuery();
    

    }

    void GuiReservation::loadCurrentReservation()
    {

    }

    void GuiReservation::loadRelModel()
    {
    // if(model == NULL) return;
    }

    bool GuiReservation::saveCurrentRow()
    {

    //update manual all fields
    if(mapper != NULL)
        if(!mapper->submit()){
            qCCritical(QT_LOG_DB) << "mapper->submit()";
            QApplication::processEvents();
            return false;}
    
    if(!model->submitAll() ) {
        qCCritical(QT_LOG_DB) << model->lastError().text() << model->query().lastQuery();
        QMessageBox::critical(this,"Crital error", model->lastError().text());
        qCCritical(QT_LOG_DB) << "ROLLBACK TRANSACTION " << model->database().rollback();
        QApplication::processEvents();
        return false;
    }
    
    QApplication::processEvents();
    return true;
    

    }

    void GuiReservation::on_pushButton_search_clicked()
    {
    // searchedNewClient();
    // set client....
    }

    void GuiReservation::on_pushButton_cancella_clicked()
    {
    qCDebug(QT_LOG_DB) << "ROLLBACK TRANSACTION " << model->database().rollback();
    this->hide();
    this->close();
    }

    void GuiReservation::on_pushButton_annulla_clicked()
    {
    bool ok = false;
    QMessageBox msgBox;
    msgBox.setText("");
    msgBox.setInformativeText(QString("<b>Vuoi cancellare le prenotazione ?<b>"));
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Save);
    int ret = msgBox.exec();
    switch (ret) {
    case QMessageBox::Ok:
    if(model->rowCount() > 0){qCCritical(QT_LOG_GENERIC) << "Current model has more row" << model->rowCount();}
    db.deleteReservationById(model->index(0,0).data(Qt::DisplayRole).toInt());
    qCDebug(QT_LOG_DB) << "COMMIT TRANSACTION " << model->database().commit();
    ok = true;
    break;
    case QMessageBox::Discard:
    // Don't Save was clicked
    break;
    case QMessageBox::Cancel:
    // Cancel was clicked
    break;
    default:
    // should never be reached
    break;
    }
    if(ok){
    this->hide();
    this->close();
    }
    }
    @

    Thanks

    [edit: added missing coding tags @ SGaist]



  • Hello,

    I'm trying with 5.3.2, the code with virtual keyboard is more fluent than in the past. I hope than you understand code because after the copy is a little compressed

    Thanks


  • Moderators

    can you post the complete log ?



  • Hello,

    I think who I found a solution, I setted "PRAGMA journal_mode = WAL", On WIndows it work correctly but on Android crashes the application.
    What do you think?

    Thanks for your help.
    @

    /*!

    • PRAGMA journal_mode;
    • PRAGMA database.journal_mode;
    • PRAGMA journal_mode = DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF
    • PRAGMA database.journal_mode = DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF
    • This pragma queries or sets the journal mode for databases associated with the current database connection.
    • The first two forms of this pragma query the current journaling mode for database. When database is omitted, the "main" database is queried.
    • The last two forms change the journaling mode. The 4th form changes the journaling mode for a specific database connection named. Use "main" for the main database (the database that was opened by the original sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2() interface call) and use "temp" for database that holds TEMP tables. The 3rd form changes the journaling mode on all databases attached to the connection. The new journal mode is returned. If the journal mode could not be changed, the original journal mode is returned.
    • The DELETE journaling mode is the normal behavior. In the DELETE mode, the rollback journal is deleted at the conclusion of each transaction. Indeed, the delete operation is the action that causes the transaction to commit. (See the document titled Atomic Commit In SQLite for additional detail.)
    • The TRUNCATE journaling mode commits transactions by truncating the rollback journal to zero-length instead of deleting it. On many systems, truncating a file is much faster than deleting the file since the containing directory does not need to be changed.
    • The PERSIST journaling mode prevents the rollback journal from being deleted at the end of each transaction. Instead, the header of the journal is overwritten with zeros. This will prevent other database connections from rolling the journal back. The PERSIST journaling mode is useful as an optimization on platforms where deleting or truncating a file is much more expensive than overwriting the first block of a file with zeros. See also: PRAGMA journal_size_limit and SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT.
    • The MEMORY journaling mode stores the rollback journal in volatile RAM. This saves disk I/O but at the expense of database safety and integrity. If the application using SQLite crashes in the middle of a transaction when the MEMORY journaling mode is set, then the database file will very likely go corrupt.
    • The WAL journaling mode uses a write-ahead log instead of a rollback journal to implement transactions. The WAL journaling mode is persistent; after being set it stays in effect across multiple database connections and after closing and reopening the database. A database in WAL journaling mode can only be accessed by SQLite version 3.7.0 or later.
    • The OFF journaling mode disables the rollback journal completely. No rollback journal is ever created and hence there is never a rollback journal to delete. The OFF journaling mode disables the atomic commit and rollback capabilities of SQLite. The ROLLBACK command no longer works; it behaves in an undefined way. Applications must avoid using the ROLLBACK command when the journal mode is OFF. If the application crashes in the middle of a transaction when the OFF journaling mode is set, then the database file will very likely go corrupt.
    • Note that the journal_mode for an in-memory database is either MEMORY or OFF and can not be changed to a different value. An attempt to change the journal_mode of an in-memory database to any setting other than MEMORY or OFF is ignored. Note also that the journal_mode cannot be changed while a transaction is active.
    • \brief DatabaseSqlite::setJournalMode
    • \param type
    • \return true or false
      */
      bool DatabaseSqlite::setJournalMode(QString type)
      {
      if(!db.isOpen()){
      qCCritical(QT_LOG_DB) << "Errore DB non aperto";
      return false;
      }
      QSqlQuery query(db);
      if(!query.exec(QString("PRAGMA journal_mode=%1").arg(type))){
      qCCritical(QT_LOG_DB) << query.lastError() << query.lastQuery();
      return false;
      }
      return true;
      }

    @



  • I didn't resolved, sometime it does crash I don't understand.... but when I see a little delay while I close windows it do crash.

    The error is very generic.

    Have someone an idea?

    My Best Regards


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.