diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-12-21 15:02:52 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-12-21 19:21:46 +0100 |
commit | 71c555c5ae31d84dff8d9448fd2be4dab23f20a8 (patch) | |
tree | 6f45dda2443a4a41ffd478e494ae459fa3f6ffd3 /drawinglayer/source/primitive2d | |
parent | 90277a87b13074c82e2e9aa08befc08c235087f3 (diff) |
Add flush mechanism to buffered Primitives II
As sberg mentioned in previous change this might be responsible
for heap-use-after-free problems. I took a look and it seems
to be possible that the timer calls back while deletion of the
helper is in progress, so I try now to first stop the timer
and then delete so that it cannot trigger. Will see if that
works - if not I might have to use another lock...
Change-Id: I1ae27d9ed890f352904cab18c3292b449659a3ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161128
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r-- | drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx | 32 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx | 32 |
2 files changed, 45 insertions, 19 deletions
diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx b/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx index 4b5f52bbe072..537a0106d80d 100644 --- a/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx +++ b/drawinglayer/source/primitive2d/BufferedDecompositionGroupPrimitive2D.cxx @@ -66,17 +66,21 @@ void BufferedDecompositionGroupPrimitive2D::setBuffered2DDecomposition(Primitive { if (0 != maCallbackSeconds) { - if (rNew.empty()) + if (maCallbackTimer.is()) { - // no more decomposition, end callback - maCallbackTimer.clear(); + if (rNew.empty()) + { + // no more decomposition, end callback + maCallbackTimer->stop(); + maCallbackTimer.clear(); + } + else + { + // decomposition changed, touch + maCallbackTimer->setRemainingTime(salhelper::TTimeValue(maCallbackSeconds, 0)); + } } - else if (maCallbackTimer.is()) - { - // decomposition changed, touch - maCallbackTimer->setRemainingTime(salhelper::TTimeValue(maCallbackSeconds, 0)); - } - else + else if (!rNew.empty()) { // decomposition changed, start callback maCallbackTimer.set(new LocalCallbackTimer(*this)); @@ -96,6 +100,16 @@ BufferedDecompositionGroupPrimitive2D::BufferedDecompositionGroupPrimitive2D( { } +BufferedDecompositionGroupPrimitive2D::~BufferedDecompositionGroupPrimitive2D() +{ + if (maCallbackTimer.is()) + { + // no more decomposition, end callback + maCallbackTimer->stop(); + maCallbackTimer.clear(); + } +} + void BufferedDecompositionGroupPrimitive2D::get2DDecomposition( Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const diff --git a/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx b/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx index 53b6f877061b..0ed22120c6d6 100644 --- a/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx +++ b/drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx @@ -65,17 +65,21 @@ void BufferedDecompositionPrimitive2D::setBuffered2DDecomposition(Primitive2DCon { if (0 != maCallbackSeconds) { - if (rNew.empty()) + if (maCallbackTimer.is()) { - // no more decomposition, end callback - maCallbackTimer.clear(); + if (rNew.empty()) + { + // no more decomposition, end callback + maCallbackTimer->stop(); + maCallbackTimer.clear(); + } + else + { + // decomposition changed, touch + maCallbackTimer->setRemainingTime(salhelper::TTimeValue(maCallbackSeconds, 0)); + } } - else if (maCallbackTimer.is()) - { - // decomposition changed, touch - maCallbackTimer->setRemainingTime(salhelper::TTimeValue(maCallbackSeconds, 0)); - } - else + else if (!rNew.empty()) { // decomposition changed, start callback maCallbackTimer.set(new LocalCallbackTimer(*this)); @@ -95,7 +99,15 @@ BufferedDecompositionPrimitive2D::BufferedDecompositionPrimitive2D() { } -BufferedDecompositionPrimitive2D::~BufferedDecompositionPrimitive2D() {} +BufferedDecompositionPrimitive2D::~BufferedDecompositionPrimitive2D() +{ + if (maCallbackTimer.is()) + { + // no more decomposition, end callback + maCallbackTimer->stop(); + maCallbackTimer.clear(); + } +} void BufferedDecompositionPrimitive2D::get2DDecomposition( Primitive2DDecompositionVisitor& rVisitor, |