Project

General

Profile

Wt::Dbo::ptr: null dereference

Added by alex merge over 8 years ago

Hi. Im just trying to do basic easy things. Adding a row to Wt::Dbo::QueryModel and modifying one field throws the "Wt::Dbo::ptr: null dereference" exception.

Actually if im trying to work with database session im getting "QueryModel: geometry inconsistent with database" error after reloading the model. Please help.

namespace Wt
{
namespace Dbo
{
template<>
struct dbo_traits<MetaUser> : public dbo_default_traits
{
    typedef Wt::WString IdType;

    static IdType invalidId()
    {
        return Wt::WString();
    }
    static const char *surrogateIdField()
    {
        return 0;
    }
};
}
}
.......
class MetaUser
{
public:
    enum Role
    {
        admin,anonim
    };

    Wt::WString m_sName;
    Role m_eRole;
    Wt::WString m_sLoginName;
    Wt::WString m_sSirname;
    Wt::WString m_sExtraInfo;
    Wt::Dbo::collection<Wt::Dbo::ptr<MetaProject> > m_cMetaProjects;
    template<class Action> void persist(Action& a)
    {
        Wt::Dbo::field(a, m_sName, "name");
        Wt::Dbo::id(a, m_sLoginName, "login");
        Wt::Dbo::field(a, m_eRole, "role");
        Wt::Dbo::field(a, m_sSirname, "sirname");
        Wt::Dbo::field(a, m_sExtraInfo, "extra_info");
        Wt::Dbo::hasMany(a, m_cMetaProjects, Wt::Dbo::ManyToOne, "login");
    }
    MetaUser() :
            m_eRole(anonim)
    {
    }
    ;
    virtual ~MetaUser()
    {
    }
    ;
};

.....

bool AdminApUsersWdg::tryToAddUserLogin(const Wt::WString& s, Wt::Dbo::QueryModel<Wt::Dbo::ptr<MetaUser> >& model)
{
    try
    {
        int row_number = model.rowCount() ;
        model.insertRow( row_number);
        model.setData(row_number,0,s);
        return true;
    } catch (Wt::Dbo::Exception& e)
    {
        std::cout << "sql error ------------------" << e.what();
        return false;
    }
}