Commit d1435c13 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Make sanity checks in the scanline fill more relaxed

Basically, we should use safe asserts for them to ensure that the
user doesn't have a data-loss.

CCBUG:408889
parent 165e1dca
......@@ -97,12 +97,20 @@ void KisFillIntervalMap::cropInterval(KisFillInterval *interval)
#ifdef ENABLE_FILL_SANITY_CHECKS
else if (it->start > interval->start && it->end < interval->end) {
SANITY_ASSERT_MSG(0, "FATAL: The backward interval cannot fully reside inside the forward interval");
it->invalidate();
interval->invalidate();
it->invalidate();
it = range.rowMapIt->erase(it);
needsIncrement = false;
}
SANITY_ASSERT_MSG(it == range.endIt || it->isValid(), "FATAL: The backward interval cannot become invalid during the crop action");
// The code above should have removed the invalidated backward interval,
// just verify that
KIS_SAFE_ASSERT_RECOVER((it == range.endIt || it->isValid()) &&
"FATAL: The backward interval cannot become "
"invalid during the crop action") {
it = range.rowMapIt->erase(it);
needsIncrement = false;
}
#endif /* ENABLE_FILL_SANITY_CHECKS */
if (needsIncrement) {
......
......@@ -28,7 +28,7 @@
#include <stdexcept>
#define SANITY_ASSERT_MSG(cond, msg) ((!(cond)) ? throw std::invalid_argument(msg) : qt_noop())
#else
#define SANITY_ASSERT_MSG(cond, msg) Q_ASSERT((cond))
#define SANITY_ASSERT_MSG(cond, msg) KIS_SAFE_ASSERT_RECOVER_NOOP((cond))
#endif /* ENABLE_CHECKS_FOR_TESTING */
#else
......
......@@ -360,9 +360,9 @@ struct Q_DECL_HIDDEN KisScanlineFill::Private
inline void swapDirection() {
rowIncrement *= -1;
SANITY_ASSERT_MSG(forwardStack.isEmpty(),
"FATAL: the forward stack must be empty "
"on a direction swap");
KIS_SAFE_ASSERT_RECOVER_NOOP(forwardStack.isEmpty() &&
"FATAL: the forward stack must be empty "
"on a direction swap");
forwardStack = QStack<KisFillInterval>(backwardMap.fetchAllIntervals(rowIncrement));
backwardMap.clear();
......
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