Hi Vladimir,<br>&nbsp; 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">&lt;<a href="mailto:ks.vladimir@gmail.com">ks.vladimir@gmail.com</a>&gt;</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&#39;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.&nbsp;</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>&nbsp;&nbsp;&nbsp; bool selected = selectionModel()-&gt;isSelected(solverIndex());<br>&nbsp;&nbsp;&nbsp; bool current = selectionModel()-&gt;currentIndex() == solverIndex();<br>&nbsp;&nbsp;&nbsp; beginRemoveRows(QModelIndex(), 1, 1);<br>&nbsp;&nbsp;&nbsp; StepCore::Solver* oldSolver = _world-&gt;removeSolver();<br>
&nbsp;&nbsp;&nbsp; endRemoveRows();<br>&nbsp;&nbsp;&nbsp; beginInsertRows(QModelIndex(), 1, 1);<br>&nbsp;&nbsp;&nbsp; _world-&gt;setSolver(solver);<br>&nbsp;&nbsp;&nbsp; endInsertRows();<br>&nbsp;&nbsp;&nbsp; if(selected) selectionModel()-&gt;select(solverIndex(), QItemSelectionModel::Select);<br>
&nbsp;&nbsp;&nbsp; if(current) selectionModel()-&gt;setCurrentIndex(solverIndex(), QItemSelectionModel::Current);<br>&nbsp;&nbsp;&nbsp; emitChanged(true, true);<br>&nbsp;&nbsp;&nbsp; return oldSolver;<br>}<br><br>Everything seems to be fine until first call goes to beginRemoveRows ()<br>
and then to _world-&gt;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> &nbsp;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>