From 0c667fd9c43fcd22d7f7d95480fd8c8539acd027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 26 Nov 2014 22:55:59 +0100 Subject: [PATCH] fixed regresion adding lists --- YACReaderLibrary/db/reading_list_model.cpp | 4 ++++ YACReaderLibrary/library_window.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/YACReaderLibrary/db/reading_list_model.cpp b/YACReaderLibrary/db/reading_list_model.cpp index 288d4cf0..2674556a 100644 --- a/YACReaderLibrary/db/reading_list_model.cpp +++ b/YACReaderLibrary/db/reading_list_model.cpp @@ -256,12 +256,16 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex & bool ReadingListModel::isEditable(const QModelIndex &mi) { + if(!mi.isValid()) + return false; ListItem * item = static_cast(mi.internalPointer()); return typeid(*item) != typeid(SpecialListItem); } bool ReadingListModel::isReadingList(const QModelIndex &mi) { + if(!mi.isValid()) + return false; ListItem * item = static_cast(mi.internalPointer()); return typeid(*item) == typeid(ReadingListItem); } diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b05542a3..58381061 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1600,7 +1600,9 @@ void LibraryWindow::addNewReadingList() if (ok) { QModelIndexList selectedLists = listsView->selectionModel()->selectedIndexes(); - QModelIndex sourceMI = listsModelProxy->mapToSource(selectedLists.at(0)); + QModelIndex sourceMI; + if(!selectedLists.isEmpty()) + sourceMI = listsModelProxy->mapToSource(selectedLists.at(0)); if(selectedLists.isEmpty() || !listsModel->isReadingList(sourceMI)) listsModel->addReadingList(newListName); //top level else