- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on a custom context in C++ and I was getting crashes when using undo, specifically from a heap corruption according to the debugger.
When I run my custom toolCommand, undo it, and then do something else, the crash occurs.
I traced the issue to the process that deletes the entries from the undo stack when we do something after undoing.
The issue occurs if commandC (the instance of my custom command) has an MRichSelection as a variable. When Maya tries to delete all the commandC data, deleting the MRichSelection is causing the corruption to occur.
If the MRichSelection is the default MRichSelection() then the issue does not occur.
This issue only seems to occur with MRichSelection, not MSelectionList (those are the two classes I tested).
Specs:
Compiling using VS2017
OS: Windows 8
Graphics: tested with Intel(R) HD Graphics 4600 and NVIDIA GeForce GTX 850M (most up to date drivers on both)
Maya Version: tested on 2020 and 2022
I have attached the minimal code needed to reproduce the issue.
To trigger the crash follow the below :
import maya.mel as mel
cmds.loadPlugin('...')
# You need to run this one line at a time to actually be in component mode
cmds.polySphere()
cmds.selectMode(component=True )
cmds.select('pSphere1.vtx[0]')
# Make sure soft select is on!
mel.eval('setToolTo {}'.format('weightSculptContext1'))
# Click twice
# undo twice
# Click
# pan camera
I have also attached a video of the crash occurring.
Let me know if any other information would be helpful.
Solved! Go to Solution.