> May need a deeper fix by tracing where the wrong index comes from.
> Either the "select_page" should not happen for a non-existing page, or
> at least it should not find a treepath for this page...

You want deeper tracing? I can tell you where the wrong index comes
from. :D

1. select_page should happen:

After a move, open_page is called on the new page location (good!) and
again triggers select_page (good!) to update the TreeView. select_page
(obviously) is designed with a page *switch* in mind and wants to notify
the previously selected TreeView item (that it's not selected anymore) -
which is why it caches the paths in the first place - and the newly
selected item (that it's now selected). Of course in the present
situation, the previously selected item doesn't exist anymore, while its
path is still cached in self.selected_page.

My fix effectivly just skips the notification of the previously selected
path, which is what I assumed acceptable behaviour.

2. it should find a treepath

There is a reason, why I call ui.open_page with an IndexPath in the unit
test *evil grin* : the IndexPath instance contains/stores the (later
invalid) index. get_treepath when called with an IndexPath skips the
lookup_path and heads right to the loop calling get_page_index.
get_page_index builds the index entires by querying pages with the same
parent and *lower* sortkey or basename. It doesn't care whether the RHS
of the comparison (the path for which it is called) exists!

Why didn't I fix get_page_index? - Well I tried to and even had a
revision in my branch that let it check the input path for existance
first. The problem here is, that get_page_index for some reason must
work the way it does and return sane results for yet uncached pages.
That's the point where I stopped digging. Also having in mind that
you're doing some refactoring on the backend stuff which might replace
this anyway at some point...

Hence, I reckoned letting get_iter crash in a controlled way (hence my
fix) is not the worst thing to do, for now at least. ;)

Cheers, Fabian

--

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/915037

Title:
  zim crashed with ValueError in select_page(): invalid tree path

To manage notifications about this bug go to:
https://bugs.launchpad.net/zim/+bug/915037/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to