Hi Koen,

Thanks it works great now.

I've noticed another issues with QueryModel.
I don't know if i'm doing something wrong, but here is the scenario:

I have something like this:

class A
{
    template <typename Action>
    void persist(Action &a)
    {
         dbo::hasMany(a, m_Cs, dbo::ManyToOne, "a");
    }
    dbo::collection< dbo::ptr<C> > m_Cs;
};

class B
{
    template <typename Action>
    void persist(Action &a)
    {
         dbo::hasMany(a, m_Cs, dbo::ManyToOne, "b");
    }
    dbo::collection< dbo::ptr<C> > m_Cs;
};

class C
{
    template <typename Action>
    void persist(Action &a)
    {
         dbo::belongsTo(a, m_A "a");
         dbo::belongsTo(a, m_B "b");
    }
    dbo::ptr<A> m_A;
    dbo::ptr<B> m_B;
};

Next i have a WTabWidget with three tabs displaying the three tables above,
using WTableView and QueryModel<A>, QueryModel<B>  and QueryModel<C>.
Initial/current widget is table A.

After initially shown table A, i click on tab with table B, table B is shown
correctly;

But after initially shown table A, i click on tab with table C, and after
that i try to click the tab with table B, an exception is thrown and session
dies.

The exception is std::logic_error("Dbo load(): no active transaction"),
thrown by Session::implLoad (Dbo/Session_impl.h line number:316).

The call stack is something like this:

Wt::Dbo::Session::implLoad<User>(Wt::Dbo::MetaDbo<User> & dbo={...},
Wt::Dbo::SqlStatement * statement=0x00000000, int & column=0)  Line 316 C++
Wt::Dbo::MetaDbo<User>::doLoad()  Line 208 C++
Wt::Dbo::MetaDbo<User>::obj()  Line 174 C++
Wt::Dbo::ptr<User>::operator bool()  Line 297 + 0x14 bytes C++
Wt::Dbo::ToAnysAction::visit<User>(const Wt::Dbo::ptr<User> & obj={...})
 Line 510 + 0x8 bytes C++
Wt::Dbo::query_result_traits<Wt::Dbo::ptr<User> >::getValues(const
Wt::Dbo::ptr<User> & ptr={...},
std::vector<boost::any,std::allocator<boost::any> > &
values=[2]({content=0x05612d88 },{content=0x05612d40 }))  Line 431 C++
Wt::Dbo::QueryModel<Wt::Dbo::ptr<User> >::setCurrentRow(int row=0)  Line 138
+ 0x12 bytes C++
Wt::Dbo::QueryModel<Wt::Dbo::ptr<User> >::data(const Wt::WModelIndex &
index={...}, int role=6)  Line 126 C++
Wt::WModelIndex::data(int role=6)  Line 25 + 0x21 bytes C++
Wt::WItemDelegate::update(Wt::WWidget * widget=0x00000000, const
Wt::WModelIndex & index={...}, Wt::WFlags<enum Wt::ViewItemRenderFlag>
flags={...})  Line 120 + 0x40 bytes C++
Wt::WTableView::renderWidget(Wt::WWidget * widget=0x00000000, const
Wt::WModelIndex & index={...})  Line 315 + 0x24 bytes C++
Wt::WTableView::renderTable(const int fr=0, const int lr=0, const int fc=0,
const int lc=0)  Line 639 + 0x53 bytes C++
Wt::WTableView::rerenderData()  Line 764 C++
Wt::WTableView::render(Wt::WFlags<enum Wt::RenderFlag> flags={...})  Line
737 C++
.
.
.

As far as i could analyze it , it seems that when table C is fetched before
table B ( table C references the table B ), rows from B are not fully loaded
but cached, and when table B is shown QueryModel assumes that rows from
table B are fully loaded and query_result_traits::getValues call from
QueryModel::setCurrentRow fails.
I tried to wrap the call with Dbo::Transaction and it was working but i do
not know if this is the right way.

The call stack is copy & paste from Visual Studio 2008's call stack view.

Thanks



On Wed, Dec 1, 2010 at 2:03 PM, Koen Deforche <[email protected]> wrote:

> 2010/11/29 Zoran Angelov <[email protected]>:
> > Hi Koen,
> > I think that i've found 2 issues with Postgres dbo backend:
> > 1. When binding a bytearray (std::vector<unsigned char>) and the array is
> > empty, on  inserting a new  record ( PostgresStatement::bind
> postgre...@150
> > ), memcpy crashes the application.
> >     Maybe zero-length check on bytearray is needed.
>
> Indeed! I've added this check.
>
> > 2. When retrieving the result of binded bytearray, after the bytearray
> has
> > been unescaped with PQunescapeBytea ( PostgresStatement::getResult
> > postgre...@384 ) freemem crashes the application.
> >     I think that memory allocated by PQunescapeBytea needs to be freed
> with
> > PQfreemem. I tried with PQfreemem and there was no crash.
>
> I cannot recall anymore why I don't use PQfreemem there, apparently it
> doesn't make a difference on linux/Unix.
>
> Both issues will be fixed soon in our git repo.
>
> Regards,
> koen
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to