Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 065b4d49 authored by Torsten Rahn's avatar Torsten Rahn Committed by Torsten Rahn

Do away with the crashes that were triggered by the

m_lastPlacemarkAt-Pointer's QPixmap-getters being evaluated
at a point where the pixmap wasn't accessible anymore.
This did lead to seldom crashes during (rapid) zooming and panning
while the mousepointer hovered placemarks.
parent 08cb69b7
......@@ -123,7 +123,7 @@ PlacemarkLayout::PlacemarkLayout( QAbstractItemModel *placemarkModel,
m_maxLabelHeight(maxLabelHeight()),
m_styleResetRequested( true ),
m_styleBuilder(styleBuilder),
m_lastPlacemarkAt(nullptr)
m_lastPlacemarkAvailable(false)
{
Q_ASSERT(m_placemarkModel);
......@@ -197,7 +197,9 @@ void PlacemarkLayout::styleReset()
void PlacemarkLayout::clearCache()
{
m_paintOrder.clear();
m_lastPlacemarkAt = nullptr;
m_lastPlacemarkAvailable = false;
m_lastPlacemarkLabelRect = QRectF();
m_lastPlacemarkSymbolRect = QRectF();
m_labelArea = 0;
qDeleteAll( m_visiblePlacemarks );
m_visiblePlacemarks.clear();
......@@ -376,7 +378,9 @@ QVector<VisiblePlacemark *> PlacemarkLayout::generateLayout( const ViewportParam
m_rowsection.resize(secnumber);
m_paintOrder.clear();
m_lastPlacemarkAt = nullptr;
m_lastPlacemarkAvailable = false;
m_lastPlacemarkLabelRect = QRectF();
m_lastPlacemarkSymbolRect = QRectF();
m_labelArea = 0;
// First handle the selected placemarks as they have the highest priority.
......@@ -541,14 +545,16 @@ bool PlacemarkLayout::hasPlacemarkAt(const QPoint &pos)
styleReset();
}
if (m_lastPlacemarkAt &&
(m_lastPlacemarkAt->labelRect().contains(pos) || m_lastPlacemarkAt->symbolRect().contains(pos))) {
if (m_lastPlacemarkAvailable &&
(m_lastPlacemarkLabelRect.contains(pos) || m_lastPlacemarkSymbolRect.contains(pos))) {
return true;
}
for(VisiblePlacemark* mark: m_paintOrder) {
if (mark->labelRect().contains(pos) || mark->symbolRect().contains(pos)) {
m_lastPlacemarkAt = mark;
m_lastPlacemarkLabelRect = mark->labelRect();
m_lastPlacemarkSymbolRect = mark->symbolRect();
m_lastPlacemarkAvailable = true;
return true;
}
}
......
......@@ -168,7 +168,11 @@ class PlacemarkLayout : public QObject
int m_maxLabelHeight;
bool m_styleResetRequested;
const StyleBuilder* m_styleBuilder;
QPointer<VisiblePlacemark> m_lastPlacemarkAt;
// Referencing these properties by value
// instead of using a more fragile pointer
bool m_lastPlacemarkAvailable;
QRectF m_lastPlacemarkLabelRect;
QRectF m_lastPlacemarkSymbolRect;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment