Commit a43a0587 authored by Tomas Mecir's avatar Tomas Mecir
Browse files

Disable the style cache, it's causing more problems than it's worth.

BUG: 368852
BUG: 391018
BUG: 448587
BUG: 449729
parent b4c7c3c6
Pipeline #179184 passed with stage
in 18 minutes and 42 seconds
......@@ -28,7 +28,7 @@ class Q_DECL_HIDDEN StyleStorage::Private
public:
Private()
#ifdef CALLIGRA_SHEETS_MT
: cacheMutex(QMutex::Recursive)
// : cacheMutex(QMutex::Recursive)
#endif
{
m_storingUndo = false;
......@@ -40,11 +40,11 @@ public:
Region usedArea;
QMap<Style::Key, QList<SharedSubStyle> > subStyles;
QMap<int, QPair<QRectF, SharedSubStyle> > possibleGarbage;
QCache<QPoint, Style> cache;
Region cachedArea;
// QCache<QPoint, Style> cache;
// Region cachedArea;
StyleStorageLoaderJob* loader;
#ifdef CALLIGRA_SHEETS_MT
QMutex cacheMutex;
// QMutex cacheMutex;
#endif
bool m_storingUndo;
......@@ -93,13 +93,13 @@ void StyleStorageLoaderJob::run()
d->usedArea = Region();
d->usedColumns.clear();
d->usedRows.clear();
{
// {
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker(&d->cacheMutex);
// QMutexLocker(&d->cacheMutex);
#endif
d->cachedArea = Region();
d->cache.clear();
}
// d->cachedArea = Region();
// d->cache.clear();
// }
typedef QPair<Region, Style> StyleRegion;
for (const StyleRegion& styleArea : m_styles) {
const Region& reg = styleArea.first;
......@@ -167,7 +167,7 @@ StyleStorage::StyleStorage(Map* map)
, d(new Private)
{
d->map = map;
d->cache.setMaxCost(g_maximumCachedStyles);
// d->cache.setMaxCost(g_maximumCachedStyles);
d->loader = 0;
}
......@@ -201,45 +201,45 @@ Style StyleStorage::contains(const QPoint& point) const
if (!d->usedArea.contains(point) && !d->usedColumns.contains(point.x()) && !d->usedRows.contains(point.y()))
return *styleManager()->defaultStyle();
{
// {
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker ml(&d->cacheMutex);
// QMutexLocker ml(&d->cacheMutex);
#endif
// first, lookup point in the cache
if (d->cache.contains(point)) {
Style st = *d->cache.object(point);
//if (point.x() == 1 && point.y() == 1) {debugSheetsStyle <<"StyleStorage: cached style:"<<point<<':'; st.dump();}
return st;
}
}
// if (d->cache.contains(point)) {
// Style st = *d->cache.object(point);
// //if (point.x() == 1 && point.y() == 1) {debugSheetsStyle <<"StyleStorage: cached style:"<<point<<':'; st.dump();}
// return st;
// }
// }
// not found, lookup in the tree
QList<SharedSubStyle> subStyles = d->tree.contains(point);
//if (point.x() == 1 && point.y() == 1) {debugSheetsStyle <<"StyleStorage: substyles:"<<point<<':'; for (const SharedSubStyle &s : subStyles) {debugSheetsStyle<<s.data()->debugData();}}
if (subStyles.isEmpty()) {
Style *style = styleManager()->defaultStyle();
// let's try caching empty styles too, the lookup is rather expensive still
{
// {
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker ml(&d->cacheMutex);
// QMutexLocker ml(&d->cacheMutex);
#endif
// insert style into the cache
d->cache.insert(point, style);
d->cachedArea.add(QRect(point, point));
}
// d->cache.insert(point, style);
// d->cachedArea.add(QRect(point, point));
// }
return *style;
}
Style* style = new Style();
(*style) = composeStyle(subStyles);
{
// {
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker ml(&d->cacheMutex);
// QMutexLocker ml(&d->cacheMutex);
#endif
// insert style into the cache
d->cache.insert(point, style);
d->cachedArea.add(QRect(point, point));
}
// d->cache.insert(point, style);
// d->cachedArea.add(QRect(point, point));
// }
//if (point.x() == 1 && point.y() == 1) {debugSheetsStyle <<"StyleStorage: style:"<<point<<':'; style->dump();}
return *style;
}
......@@ -677,10 +677,10 @@ void StyleStorage::invalidateCache()
return;
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker ml(&d->cacheMutex);
// QMutexLocker ml(&d->cacheMutex);
#endif
d->cache.clear();
d->cachedArea = Region();
// d->cache.clear();
// d->cachedArea = Region();
}
void StyleStorage::garbageCollection()
......@@ -842,19 +842,19 @@ void StyleStorage::invalidateCache(const QRect& rect)
return;
#ifdef CALLIGRA_SHEETS_MT
QMutexLocker ml(&d->cacheMutex);
// QMutexLocker ml(&d->cacheMutex);
#endif
// debugSheetsStyle <<"StyleStorage: Invalidating" << rect;
const Region region = d->cachedArea.intersected(Region(rect));
d->cachedArea.removeIntersects(rect, nullptr);
for (const QRect& rect : region.rects()) {
for (int col = rect.left(); col <= rect.right(); ++col) {
for (int row = rect.top(); row <= rect.bottom(); ++row) {
// const Region region = d->cachedArea.intersected(Region(rect));
// d->cachedArea.removeIntersects(rect, nullptr);
// for (const QRect& rect : region.rects()) {
// for (int col = rect.left(); col <= rect.right(); ++col) {
// for (int row = rect.top(); row <= rect.bottom(); ++row) {
// debugSheetsStyle <<"StyleStorage: Removing cached style for" << Cell::name( col, row );
d->cache.remove(QPoint(col, row)); // also deletes it
}
}
}
// d->cache.remove(QPoint(col, row)); // also deletes it
// }
// }
// }
}
Style StyleStorage::composeStyle(const QList<SharedSubStyle>& subStyles) const
......
Supports Markdown
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