void tst_QUndoGroup::addStackAndDie() { // Test that QUndoStack doesn't keep a reference to QUndoGroup after the // group is deleted. QUndoStack *stack = new QUndoStack; QUndoGroup *group = new QUndoGroup; group->addStack(stack); delete group; stack->setActive(true); delete stack; }
void tst_QUndoGroup::addRemoveStack() { QUndoGroup group; QUndoStack stack1(&group); QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1); QUndoStack stack2; group.addStack(&stack2); QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); group.addStack(&stack1); QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); group.removeStack(&stack1); QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); group.removeStack(&stack1); QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); group.removeStack(&stack2); QCOMPARE(group.stacks(), QList<QUndoStack*>()); }
void tst_QUndoGroup::setActive() { QUndoGroup group; QUndoStack stack1(&group), stack2(&group); QCOMPARE(group.activeStack(), (QUndoStack*)0); QCOMPARE(stack1.isActive(), false); QCOMPARE(stack2.isActive(), false); QUndoStack stack3; QCOMPARE(stack3.isActive(), true); group.addStack(&stack3); QCOMPARE(stack3.isActive(), false); stack1.setActive(); QCOMPARE(group.activeStack(), &stack1); QCOMPARE(stack1.isActive(), true); QCOMPARE(stack2.isActive(), false); QCOMPARE(stack3.isActive(), false); group.setActiveStack(&stack2); QCOMPARE(group.activeStack(), &stack2); QCOMPARE(stack1.isActive(), false); QCOMPARE(stack2.isActive(), true); QCOMPARE(stack3.isActive(), false); group.removeStack(&stack2); QCOMPARE(group.activeStack(), (QUndoStack*)0); QCOMPARE(stack1.isActive(), false); QCOMPARE(stack2.isActive(), true); QCOMPARE(stack3.isActive(), false); group.removeStack(&stack2); QCOMPARE(group.activeStack(), (QUndoStack*)0); QCOMPARE(stack1.isActive(), false); QCOMPARE(stack2.isActive(), true); QCOMPARE(stack3.isActive(), false); }
static PyObject *meth_QUndoGroup_addStack(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QUndoStack* a0; QUndoGroup *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8", &sipSelf, sipType_QUndoGroup, &sipCpp, sipType_QUndoStack, &a0)) { Py_BEGIN_ALLOW_THREADS sipCpp->addStack(a0); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QUndoGroup, sipName_addStack, doc_QUndoGroup_addStack); return NULL; }