Skip to content

Commit

Permalink
Do index check before access in contextmenu
Browse files Browse the repository at this point in the history
Fix #971
  • Loading branch information
juuz0 committed Aug 3, 2023
1 parent 5d047a9 commit cc4ccaf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/contentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ QList<QMap<QString, QVariant>> ContentManager::getBooksList()
void ContentManager::onCustomContextMenu(const QPoint &point)
{
QModelIndex index = mp_view->getView()->indexAt(point);
if (!index.isValid())
return;
QMenu contextMenu("optionsMenu", mp_view->getView());
auto bookNode = static_cast<RowNode*>(index.internalPointer());
const auto id = bookNode->getBookId();
Expand Down Expand Up @@ -154,9 +156,7 @@ void ContentManager::onCustomContextMenu(const QPoint &point)
resumeBook(id, index);
});

if (index.isValid()) {
contextMenu.exec(mp_view->getView()->viewport()->mapToGlobal(point));
}
contextMenu.exec(mp_view->getView()->viewport()->mapToGlobal(point));
}

void ContentManager::setLocal(bool local) {
Expand Down

0 comments on commit cc4ccaf

Please sign in to comment.