Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting the same prim twice and clearing the selection crashes AL_USDMaya #21

Open
sirpalee opened this issue Aug 15, 2017 · 0 comments

Comments

@sirpalee
Copy link
Contributor

The selected prims can stack up in helper.m_paths, then their reference counts are going below zero.

A quick workaround for this problem is to avoid storing the same path twice, but in the long term a second look at the internal reference counting, and avoiding crashing Maya on invalid states is a better option.

diff --git a/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp b/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp
index 4503116..6f8465e 100644
--- a/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp
+++ b/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp
@@ -1040,7 +1040,15 @@ bool ProxyShape::doSelect(SelectionUndoHelper& helper)
         }
       }
 
-      helper.m_paths.insert(helper.m_paths.end(), helper.m_previousPaths.begin(), helper.m_previousPaths.end());
+      const auto newSize = helper.m_paths.size() + helper.m_previousPaths.size();
+      if (helper.m_paths.capacity() < newSize) {
+        helper.m_paths.reserve(newSize);
+      }
+      for (const auto& path : helper.m_previousPaths) {
+        if (std::find(helper.m_paths.begin(), helper.m_paths.end(), path) == helper.m_paths.end()) {
+          helper.m_paths.push_back(path);
+        }
+      }
 
       uint32_t hasNodesToCreate = 0;
       for(auto prim : prims)
seando-adsk pushed a commit to autodesk-forks/AL_USDMaya that referenced this issue Nov 19, 2018
* MAYA-94667 deselect USD objs by clicking void area

* MAYA-94667 code review suggestions

* MAYA-94667 code review suggestion
seando-adsk pushed a commit to autodesk-forks/AL_USDMaya that referenced this issue Nov 27, 2018
1. glext.h is not in the devkit anymore, switching files

2. Adding chrono for windows only

3. Adding python libraries to fix link issue

4. MAYA-xxxx Integrating UFE into AL_USDMaya plugin
- Integration of the UFE libraries include cmake lookup and cmake on/off
  variables to enable and disable compilation with UFE
- Integration of a runtime variable to switch on/off UFE selection with
  the plugin
- Integrate UFE selection and disabling creation of proxy nodes for usd
   prim selections

5. Updating runtime id, separator of USD, and adding an added header in the want ufe build ompile

6. Missing header file

7. Merging 0.28.5 into dev-adsk (AnimalLogic#9)

8. Windows build fixes: (AnimalLogic#10)
* Remove treat warnings as errors (/WX)
* Multiline (with \) the C++ options

9. Show the UFE selection in the viewport (AnimalLogic#11)

* Show the UFE selection in the viewport

* When drawing the override, if the env var MAYA_WANT_UFE_SELECTION is
  set get the UFE selection and for the USD items draw them in wireframe
  with the Maya selection color.

* Code review: adding code comments

* Fix spelling mistake

10. Changing PATHS to HINTS in cmake file

11. Windows build fixes (AnimalLogic#13)

* MAYA-93327 - Integrate USD in Maya

* Install the Windows .pdb files.

* Add UFE build define when cmake flag is set.

* Fix relative library path for plugInfo.json files.

* Build schemas/plugInfo.json in binary folder (not source).
  So git status is not dirtied.

* Use UFE_VERSION (instead of hard-coded value) which is set above this
  repo when building.

* When building with UFE, we must have the UFE version defined.

* Code review comments - build ufe major/minor vars in the parent rather
  than child (FindUFE.cmake). This way they are accessible to others.

12. MAYA-93327 - Integrate USD in Maya (AnimalLogic#14)

* RPATH has been deprecated in favor or RUNPATH which is same except
  that it is searched after LD_LIBRARY_PATH. This gives users the ability
  to override the shared libraries.

13. Use local UFE and versioning fix.

14. Convert FindUFE.cmake to LF line endings.

15. Improved USD selection highlighting.

16. MAYA-88299 - Versioning for UFE and API (AnimalLogic#16)

* UFE lib/dll/so/dylib with major only version (no minor).

17. Merging master (0.29.1) into dev-adsk (AnimalLogic#17)

18. MAYA-94776 - Update USD plugin to latest AL branch (AnimalLogic#18)

* Adding missing pdb file for new plugin file.

19. MAYA-94776 - Update 'dev-adsk' to latest 'develop' to get VP2 Selection code (AnimalLogic#19)

20. MAYA-95136 consistent behavior with legacy VP1 selection (AnimalLogic#20)

21. MAYA-94667 deselect USD objs by clicking void area (AnimalLogic#21)

* MAYA-94667 deselect USD objs by clicking void area

* MAYA-94667 code review suggestions

* MAYA-94667 code review suggestion

22. MAYA-95136 selection under complex transform nodes (AnimalLogic#22)

23. MAYA-95391 revert regression change (AnimalLogic#23)

24. MAYA-95391 RMB click shouldn't trigger selection (AnimalLogic#24)

Port the VP1 implementation in ProxyShapeUI::select().

25. MAYA-95322 update bounding box of AL_MayaUSD proxy shape (AnimalLogic#25)

* MAYA-95322 update bounding box of AL_MayaUSD proxy shape

* MAYA-95322 code review feedback

26. Temporary restore alwaysDirty ProxyDrawOrride

(cherry picked from commit 6060036)

MAYA-95165 : Crash when duplicating USD objects

   The regression was introduced by the commit https://git.autodesk.com/autodesk-forks/AL_USDMaya/commit/321be29175a43aa270bb9d50387ac335c0d483d0
   To avoid that problem we cherry-picked the correction from the last
   updates in the develop branch.

27. MAYA-95627 - Update to latest AL develop branch v0.29.4 + USD v18.11

Merge branch 'develop' into donnels/merging_in_develop_0.29.4

28. MAYA-95627 - Update to latest AL develop branch v0.29.4 + USD v18.11

* Fixing merge (of develop branch into dev-adsk) error.

29. MAYA-95627 - Update to latest AL develop branch v0.29.4 + USD v18.11 (AnimalLogic#28)

* Some minor fixes related to merging discovered when trying to merge
  our 'dev-adsk' branch into 'develop'.

30. Comment from initial pull request to AL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants