Delete object without passing by RAddObjectsOperation

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Delete object without passing by RAddObjectsOperation

Post by sarlaa » Mon Jun 18, 2018 12:44 pm

Hi,

Please, is there a way to delete an object without passing by RAddObjectsOperation as setCustomProperty.
We want this in purpose that when we delete an object, it doesn't register as operation, and undo/redo won't take it in consideration.

Thanks.

User avatar
andrew
Site Admin
Posts: 5604
Joined: Fri Mar 30, 2007 6:07 am

Re: Delete object without passing by RAddObjectsOperation

Post by andrew » Mon Jun 18, 2018 3:37 pm

No, you should never change or delete objects directly, bypassing transactions and the undo / redo mechanism.
(Unless, perhaps when you are operating on an off-screen document without any user interaction).

Imagine this simple use case:
Step 1: line added (recorded as transaction, can be undone)
Step 2: line deleted (not recorded, cannot be undone)
Step 3: user hits undo

This would lead to a crash when trying to undo step 1, since the line referenced in step 1 has vanished and its deletion was not recorded. Normally, that line would have been restored when undoing step 2.

sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Re: Delete object without passing by RAddObjectsOperation

Post by sarlaa » Mon Jun 18, 2018 7:29 pm

I see. Thanks for your example.

Post Reply

Return to “QCAD Developers and Contributors”