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

MAYA-111932 no USD prompt during crash #1601

Merged
merged 4 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmake/modules/FindMaya.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ if (MAYA_INCLUDE_DIRS AND EXISTS "${MAYA_INCLUDE_DIR}/maya/MSelectionContext.h")
endif()
endif()

set(MAYA_HAS_CRASH_DETECTION FALSE CACHE INTERNAL "isInCrashHandler")
if(MAYA_INCLUDE_DIRS AND EXISTS "${MAYA_INCLUDE_DIR}/maya/MGlobal.h")
file(STRINGS ${MAYA_INCLUDE_DIR}/maya/MGlobal.h MAYA_HAS_API REGEX "isInCrashHandler")
if(MAYA_HAS_API)
set(MAYA_HAS_CRASH_DETECTION TRUE CACHE INTERNAL "isInCrashHandler")
message(STATUS "Maya has isInCrashHandler API")
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif()

# handle the QUIETLY and REQUIRED arguments and set MAYA_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
Expand Down
8 changes: 8 additions & 0 deletions lib/mayaUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ if (MAYA_NEW_POINT_SNAPPING_SUPPORT)
)
endif()

message(STATUS "MAYA_HAS_CRASH_DETECTION is ${MAYA_HAS_CRASH_DETECTION}")
if (MAYA_HAS_CRASH_DETECTION)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
MAYA_HAS_CRASH_DETECTION=1
)
endif()

if (MAYA_LIGHTAPI_VERSION EQUAL 2)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
Expand Down
15 changes: 14 additions & 1 deletion lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ void convertAnonymousLayersRecursive(
}
}

bool isCrashing()
{
#ifdef MAYA_HAS_CRASH_DETECTION
return MGlobal::isInCrashHandler();
#else
return false;
#endif
}

constexpr auto kSaveOptionUICmd = "usdFileSaveOptions(true);";

} // namespace
Expand Down Expand Up @@ -361,6 +370,7 @@ void LayerDatabase::prepareForWriteCheck(bool* retCode, bool isExport)
int dialogResult = true;

if (MGlobal::kInteractive == MGlobal::mayaState()
&& !isCrashing()
&& LayerDatabase::instance().saveInteractionRequired()) {
MGlobal::executeCommand(kSaveOptionUICmd, dialogResult);
}
Expand Down Expand Up @@ -448,7 +458,10 @@ bool LayerDatabase::saveUsd(bool isExport)
auto opt = MayaUsd::utils::serializeUsdEditsLocationOption();

if (MayaUsd::utils::kIgnoreUSDEdits != opt) {
if (_batchSaveDelegate && _proxiesToSave.length() > 0) {
if (isCrashing()) {
result = kPartiallyCompleted;
opt = MayaUsd::utils::kSaveToUSDFiles;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your pull request description says you'll save inside the Maya file when crashing, but your code says save to USD files. Which one should it be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Maya, thanks for catching this.

} else if (_batchSaveDelegate && _proxiesToSave.length() > 0) {
result = _batchSaveDelegate(_proxiesToSave);
}

Expand Down