Hi Vladimir,<br> I just went through the code as you suggested through gdb.<br><br><div class="gmail_quote">On Mon, Feb 2, 2009 at 2:30 AM, Vladimir Kuznetsov <span dir="ltr"><<a href="mailto:ks.vladimir@gmail.com">ks.vladimir@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
To check why it can be NULL, let's look at a point where the index is created.<br>
There are several functions in WorldModel which returns QModelIndex, but all<br>
of them uses WorldModel::solverIndex() function to obtain index for solver<br>
which in turn calls StepCore::World::solver() function which just returns<br>
_solver member of the World class.<br>
<br>
Next we have to look at where that member (World::_solver) is initialized.<br>
There is World::setSolver function that sets it and it is called by<br>
WorldModel::swapSolver function which in turn is called by CommandSetSolver<br>
class which is created in WorldModel::newSolver function. </blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
You could check using debugger whether WorldModel::newSolver receives a<br>
correct solver class name as an argument and whether the solver is created<br>
correctly. Then you could check whether it is correctly passed passed to<br>
swapSolver function.<br>
</blockquote><div><br>These are the results I got. For convenience I am pasting the<br>method here where the problem is occuring, please forgive :)<br><br>StepCore::Solver* WorldModel::swapSolver(StepCore::Solver* solver)<br>
{<br> bool selected = selectionModel()->isSelected(solverIndex());<br> bool current = selectionModel()->currentIndex() == solverIndex();<br> beginRemoveRows(QModelIndex(), 1, 1);<br> StepCore::Solver* oldSolver = _world->removeSolver();<br>
endRemoveRows();<br> beginInsertRows(QModelIndex(), 1, 1);<br> _world->setSolver(solver);<br> endInsertRows();<br> if(selected) selectionModel()->select(solverIndex(), QItemSelectionModel::Select);<br>
if(current) selectionModel()->setCurrentIndex(solverIndex(), QItemSelectionModel::Current);<br> emitChanged(true, true);<br> return oldSolver;<br>}<br><br>Everything seems to be fine until first call goes to beginRemoveRows ()<br>
and then to _world->removeSolver(), but the program crashes when<br>endRemoveRows() is called. Still not sure whats causing it. But I still did <br>not understand why a new object QModelIndex() was created and passed<br>
to beginRemoveRows. Is that causing some kind of problem? The API<br>asks to pass the parent index but we pass a newly created index.<br>Is that all Ok?<br><br><br><br>-- <br></div></div>Thanks and regards,<br> Madhusudan.C.S<br>
<br>Blogs at: <a href="http://www.madhusudancs.info">www.madhusudancs.info</a><br>Official Email ID: <a href="mailto:madhusudan@madhusudancs.info">madhusudan@madhusudancs.info</a><br>