Aydins
March 14, 2007, 9:05am
1
I am trying to make a modal TreeView selector. I want to scroll to a previously selected item.
Before ronModalLoop() I add the TreeViewItems and if I find a previously selected one:
if (selectedItem != 0)
{
treeView->scrollToKeepItemVisible(selectedItem);
selectedItem->setSelected(true, true);
}
but in
void TreeView::scrollToKeepItemVisible (TreeViewItem* item)
{
if (item != 0 && item->ownerView == this)
item->ownerView is valid but “this” is not?? So naturally it does not scroll.
What’s going on here?
jules
March 14, 2007, 9:42am
2
Well it’s checking that the item you’re trying to scroll actually belongs to the treeview. I guess you’ve not yet added the item to the tree?
Aydins
March 14, 2007, 10:19am
3
No, it’s allready added to the TreeView, in fact I can see at the debugger that the ownerView is correct, but the pointer “this” is shown as “0xcccccccc” (probably invalid pointer)?
jules
March 14, 2007, 11:23am
4
Well I’d say that’s a pretty clear sign that you’re using a dangling pointer!
Aydins
March 14, 2007, 12:27pm
5
the TreeView is my content component, and I add items to this treeview, when I send an Item (which is already added to TreeView) to Treeview’s
void TreeView::scrollToKeepItemVisible (TreeViewItem* item)
{
if (item != 0 && item->ownerView == this)
method, the “this” pointer which should show “this TreeView” (which is allready on my component and should be valid) seems to be invalid.
The confusing thing is
“item->ownerView” correctly points to this TreeView.
jules
March 14, 2007, 12:43pm
6
If ‘this’ is toasted, then obviously the pointer you’re using to call the scroll method is toast. You need to spend some quality time with your debugger.