Wt,C+++ and SIGSEGV



  • Trying to deal with the WebToolkit and write on examples his annex. But after working with the base, problems began, and the last unsolved memory leak after the model was presented and the table of elements was presented.

    manTable = new Wt::WTable();
    database *wsedb = new database();
    wsedb->dbInit();
    ...
    manView = new Wt::WTableView();
    manView->setModel(wsedb->manModel);
    manTable->elementAt(1,0)->addWidget(manView);
    

    I can't figure out how to deal with this problem. Like the type is correct, all the headings are connected, and the examples of developers work the same way. Sors: database.h:

    #ifndef DATABASE_H
    #define DATABASE_H
    #include<Wt/Dbo/backend/Sqlite3>
    #include<Wt/Dbo/Dbo>
    #include <Wt/Dbo/Session>
    #include <Wt/Dbo/QueryModel>
    #include <Wt/WApplication>
    #include "manuals.h"//map clases
    namespace dbo = Wt::Dbo;
    

    class database
    {
    public:
    database();
    dbo::Session SessionW;
    dbo::QueryModel<dbo::ptr<manuals>> *manModel;
    void dbInit();
    void dbTrans();
    void addMan();
    };

    #endif // DATABASE_H

    database.cpp:

    #include "database.h"
    using namespace Wt;

    database::database()
    {
    }

    void database::dbInit()
    {
    dbo::backend::Sqlite3 wseDB=WApplication::instance()->appRoot() + "wse.db";
    SessionW.setConnection(wseDB);
    wseDB.setProperty("show-queries", "true");
    SessionW.mapClass<manuals>("manuals");
    manModel=new dbo::QueryModel<dbo::ptr<manuals>>();
    dbo::Transaction trans(SessionW);
    try{
    SessionW.createTables();
    Wt::log("info") << "Database created";

    } catch (...) {
        Wt::log("info") &lt;&lt; "Using existing database";
    }
    trans.commit();
    manModel-&gt;setQuery(SessionW.find&lt;manuals&gt;());
    manModel-&gt;addAllFieldsAsColumns();
    dbo::Transaction trans1(SessionW);
    Wt::Dbo::collection&lt;Wt::Dbo::ptr&lt;manuals&gt; &gt; a=SessionW.find&lt;manuals&gt;().orderBy("date desc");
    trans1.commit();
    

    }



  • There's a great tool, Valgrind. Closest IDE with Valgrind support, Qt Creator.

    He's looking for both memory leaks and signposts.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2