Quote:
Originally Posted by chaley
@capink: this might have nothing to do with the problem, but this exception can happen if a search reduces the number of books that would be shown in the book list. The "index" is the row number of the book list. The exception is thrown if that row number no longer exists. For example, imagine 30 books being displayed, with book 20 selected. A search reduces the number displayed to 15, moving the selected book to row 10. Even though the current book is still there, the fact that there isn't a book 20 causes the exception to be thrown. If it wasn't thrown then you would most likely have the wrong book.
Also note that if the GUI hasn't been told about a db.search() then it will think that it has current data, which is likely wrong.
|
Thanks for the help. I think I figured out the problem. I made the wrong assumption that if no row is selected the result of gui.library_view.currentIndex() will evaluate to None and proceeded with:
Code:
if gui.library_view.currentIndex():
....
Turns out it returns a QModelIndex() that can be test by either:
Code:
if gui.library_view.currentIndex().row() >= 0:
....
or
Code:
if gui.library_view.currentIndex().row() != QModelIndex():
....
The selection modifier does not use db.search(). It performs the search directly in calibre GUI:
Code:
gui.search.set_search_string(search_string)
gui.search.do_search()
Hope this version fixes the problem.