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-109948 - Crash saving USD without opening Layer Editor #1187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions lib/usd/ui/layerEditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ target_sources(${PROJECT_NAME}
mayaLayerEditorWindow.h
mayaSessionState.cpp
mayaSessionState.h
mayaQtUtils.cpp
mayaQtUtils.h
pathChecker.cpp
pathChecker.h
qtUtils.cpp
Expand Down
8 changes: 8 additions & 0 deletions lib/usd/ui/layerEditor/batchSaveLayersUIDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@

#include "batchSaveLayersUIDelegate.h"

#include "mayaQtUtils.h"
#include "saveLayersDialog.h"

#include <mayaUsd/nodes/layerManager.h>
#include <mayaUsd/utils/utilSerialization.h>

#include <maya/MGlobal.h>

void UsdLayerEditor::initialize()
{
if (nullptr == UsdLayerEditor::utils) {
UsdLayerEditor::utils = new MayaQtUtils();
}
}

bool UsdLayerEditor::batchSaveLayersUIDelegate(const std::vector<UsdStageRefPtr>& stages)
{
if (MGlobal::kInteractive == MGlobal::mayaState()) {
Expand Down
3 changes: 3 additions & 0 deletions lib/usd/ui/layerEditor/batchSaveLayersUIDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ PXR_NAMESPACE_USING_DIRECTIVE

namespace UsdLayerEditor {

MAYAUSD_UI_PUBLIC
void initialize();

MAYAUSD_UI_PUBLIC
bool batchSaveLayersUIDelegate(const std::vector<UsdStageRefPtr>&);

Expand Down
34 changes: 4 additions & 30 deletions lib/usd/ui/layerEditor/mayaLayerEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "layerEditorWidget.h"
#include "layerTreeModel.h"
#include "layerTreeView.h"
#include "mayaQtUtils.h"
#include "mayaSessionState.h"
#include "qtUtils.h"
#include "sessionState.h"

#include <mayaUsd/utils/query.h>
Expand Down Expand Up @@ -86,33 +86,6 @@ AbstractLayerEditorCreator::PanelNamesList LayerEditorWindowCreator::getAllPanel
return result;
}

class MayaQtUtils : public QtUtils
{

double dpiScale() override { return MQtUtil::dpiScale(1.0f); }
QIcon createIcon(const char* iconName) override
{
QIcon* icon = MQtUtil::createIcon(iconName);
QIcon copy;
if (icon) {
copy = QIcon(*icon);
}
delete icon;
return copy;
}

QPixmap createPixmap(QString const& pixmapName, int width, int height) override
{
QPixmap* pixmap = MQtUtil::createPixmap(pixmapName.toStdString().c_str());
if (pixmap != nullptr) {
QPixmap copy(*pixmap);
delete pixmap;
return copy;
}
return QPixmap();
}
} g_mayaQtUtils;

} // namespace

namespace UsdLayerEditor {
Expand All @@ -122,10 +95,11 @@ MayaLayerEditorWindow::MayaLayerEditorWindow(const char* panelName, QWidget* par
, AbstractLayerEditorWindow(panelName)
, _panelName(panelName)
{
// Normally this will be set from the MayaUsd plugin, but only
// when building with UFE (for the batch save case).
if (!UsdLayerEditor::utils) {
UsdLayerEditor::utils = &g_mayaQtUtils;
UsdLayerEditor::utils = new MayaQtUtils();
}

onCreateUI();

connect(
Expand Down
47 changes: 47 additions & 0 deletions lib/usd/ui/layerEditor/mayaQtUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "mayaQtUtils.h"

#include <maya/MQtUtil.h>

namespace UsdLayerEditor {

double MayaQtUtils::dpiScale() { return MQtUtil::dpiScale(1.0f); }

QIcon MayaQtUtils::createIcon(const char* iconName)
{
QIcon* icon = MQtUtil::createIcon(iconName);
QIcon copy;
if (icon) {
copy = QIcon(*icon);
}
delete icon;
return copy;
}

QPixmap MayaQtUtils::createPixmap(QString const& pixmapName, int width, int height)
{
QPixmap* pixmap = MQtUtil::createPixmap(pixmapName.toStdString().c_str());
if (pixmap != nullptr) {
QPixmap copy(*pixmap);
delete pixmap;
return copy;
}
return QPixmap();
}

} // namespace UsdLayerEditor
34 changes: 34 additions & 0 deletions lib/usd/ui/layerEditor/mayaQtUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#ifndef MAYAQTUTILS_H
#define MAYAQTUTILS_H

#include "qtUtils.h"

namespace UsdLayerEditor {

class MayaQtUtils : public QtUtils
{
public:
double dpiScale() override;
QIcon createIcon(const char* iconName) override;
QPixmap createPixmap(QString const& pixmapName, int width, int height) override;
};

} // namespace UsdLayerEditor

#endif // MAYAQTUTILS_H
1 change: 1 addition & 0 deletions plugin/adsk/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ MStatus initializePlugin(MObject obj)
#if defined(WANT_UFE_BUILD)
MayaUsd::LayerManager::addSupportForNodeType(MAYAUSD_NS::ProxyShape::typeId);
#if defined(WANT_QT_BUILD)
UsdLayerEditor::initialize();
MayaUsd::LayerManager::SetBatchSaveDelegate(UsdLayerEditor::batchSaveLayersUIDelegate);
#endif
#endif
Expand Down