diff --git a/src/kviewstateserializer.cpp b/src/kviewstateserializer.cpp --- a/src/kviewstateserializer.cpp +++ b/src/kviewstateserializer.cpp @@ -22,6 +22,7 @@ #include "kviewstateserializer.h" #include +#include #include #include #include @@ -51,6 +52,9 @@ inline void restoreScrollBarState() { + if (!m_scrollArea) { + return; + } if (m_horizontalScrollBarValue >= 0 && m_horizontalScrollBarValue <= m_scrollArea->horizontalScrollBar()->maximum()) { m_scrollArea->horizontalScrollBar()->setValue(m_horizontalScrollBarValue); m_horizontalScrollBarValue = -1; @@ -95,7 +99,7 @@ QTreeView *m_treeView; QAbstractItemView *m_view; QItemSelectionModel *m_selectionModel; - QAbstractScrollArea *m_scrollArea; + QPointer m_scrollArea; int m_horizontalScrollBarValue; int m_verticalScrollBarValue;