From 3a28b83b6f7dabff75483c38bbc786c2ff7af321 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 15 Jan 2016 16:23:00 +0100 Subject: Do not return negative values in WebEngineHistoryListModel QSortFilterProxyModel does not like negative values which were returned when adapter was not yet initialized. Add missing guards for adapter. Change-Id: I3d1dd5343aaf2c4d5504950005b05fb650835884 Reviewed-by: Kai Koehne --- src/webengine/api/qquickwebenginehistory.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index d790093a4..050833b28 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -54,7 +54,7 @@ QQuickWebEngineHistoryListModelPrivate::~QQuickWebEngineHistoryListModelPrivate( int QQuickWebEngineHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount(); } @@ -65,6 +65,8 @@ int QQuickWebEngineHistoryListModelPrivate::index(int index) const int QQuickWebEngineHistoryListModelPrivate::offsetForIndex(int index) const { + if (!adapter()) + return index; return index - adapter()->currentNavigationEntryIndex(); } @@ -81,7 +83,7 @@ QQuickWebEngineBackHistoryListModelPrivate::QQuickWebEngineBackHistoryListModelP int QQuickWebEngineBackHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->currentNavigationEntryIndex(); } @@ -104,12 +106,14 @@ QQuickWebEngineForwardHistoryListModelPrivate::QQuickWebEngineForwardHistoryList int QQuickWebEngineForwardHistoryListModelPrivate::count() const { if (!adapter()) - return -1; + return 0; return adapter()->navigationEntryCount() - adapter()->currentNavigationEntryIndex() - 1; } int QQuickWebEngineForwardHistoryListModelPrivate::index(int i) const { + if (!adapter()) + return i + 1; return adapter()->currentNavigationEntryIndex() + i + 1; } -- cgit v1.2.3