Fix separators not being deleted

Bug found with QtQuick but also reproducible with QtWidgets.
Added unit-test for both stacks.
This commit is contained in:
Sergio Martins
2020-10-05 18:25:33 +01:00
parent b0ec0e22e4
commit 128ae2d889
4 changed files with 51 additions and 0 deletions

View File

@@ -25,6 +25,9 @@ using namespace Layouting;
Separator* Separator::s_separatorBeingDragged = nullptr;
/// @brief internal counter just for unit-tests
static int s_numSeparators = 0;
struct Separator::Private
{
// Only set when anchor is moved through mouse. Side1 if going towards left or top, Side2 otherwise.
@@ -46,10 +49,12 @@ struct Separator::Private
Separator::Separator(Widget *hostWidget)
: d(new Private(hostWidget))
{
s_numSeparators++;
}
Separator::~Separator()
{
s_numSeparators--;
delete d;
if (isBeingDragged())
s_separatorBeingDragged = nullptr;
@@ -216,6 +221,11 @@ bool Separator::isResizing()
return s_separatorBeingDragged != nullptr;
}
int Separator::numSeparators()
{
return s_numSeparators;
}
void Separator::setLazyPosition(int pos)
{
if (d->lazyPosition != pos) {