@@ -62,34 +62,39 @@ void UsdMayaJobContextRegistry::RegisterExportJobContext(
62
62
bool fromPython)
63
63
{
64
64
TF_DEBUG (PXRUSDMAYA_REGISTRY).Msg (" Registering export job context %s.\n " , jobContext.c_str ());
65
+
65
66
TfToken key (jobContext);
66
- ContextInfo newInfo { key, TfToken (niceName), TfToken (description), enablerFct, {}, {} };
67
- auto itFound = _jobContextReg.find (newInfo);
67
+ ContextInfo newInfo { key, TfToken (niceName), TfToken (description) };
68
+ newInfo.exportEnablerCallback = enablerFct;
69
+
70
+ auto itFound = _jobContextReg.find (newInfo);
68
71
if (itFound == _jobContextReg.end ()) {
69
72
_jobContextReg.insert (newInfo);
70
73
UsdMaya_RegistryHelper::AddUnloader (
71
- [key]() {
72
- ContextInfo toErase { key, {}, {}, {}, {}, {} };
73
- _jobContextReg.erase (toErase);
74
- },
75
- fromPython);
74
+ [key]() { _jobContextReg.erase (ContextInfo { key }); }, fromPython);
76
75
} else {
77
- if (!itFound->exportEnablerCallback ) {
78
- if (niceName != itFound->niceName ) {
79
- TF_CODING_ERROR (
80
- " Export enabler has differing nice name: %s != %s" ,
81
- niceName.c_str (),
82
- itFound->niceName .GetText ());
83
- }
84
- // Fill the export part:
85
- ContextInfo updatedInfo (*itFound);
86
- updatedInfo.exportDescription = TfToken (description);
87
- updatedInfo.exportEnablerCallback = enablerFct;
88
- _jobContextReg.erase (updatedInfo);
89
- _jobContextReg.insert (updatedInfo);
90
- } else {
76
+ if (itFound->exportEnablerCallback ) {
91
77
TF_CODING_ERROR (" Multiple enablers for export job context %s" , jobContext.c_str ());
92
78
}
79
+
80
+ if (itFound->niceName .size () > 0 && niceName != itFound->niceName ) {
81
+ TF_CODING_ERROR (
82
+ " Export enabler has differing nice name: %s != %s" ,
83
+ niceName.c_str (),
84
+ itFound->niceName .GetText ());
85
+ }
86
+
87
+ // Note: the container for the plugin info is a set so it cannot be modified.
88
+ // We need to copy the entry, modify the copy, remove the old entry and
89
+ // insert the newly updated entry.
90
+ ContextInfo updatedInfo (*itFound);
91
+ if (niceName.size () > 0 )
92
+ updatedInfo.niceName = TfToken (niceName);
93
+ if (description.size () > 0 )
94
+ updatedInfo.exportDescription = TfToken (description);
95
+ updatedInfo.exportEnablerCallback = enablerFct;
96
+ _jobContextReg.erase (updatedInfo);
97
+ _jobContextReg.insert (updatedInfo);
93
98
}
94
99
}
95
100
@@ -98,22 +103,27 @@ void UsdMayaJobContextRegistry::SetExportOptionsUI(
98
103
UIFn uiFct,
99
104
bool fromPython)
100
105
{
101
- const ContextInfo key { TfToken (jobContext), {}, {}, {}, {}, {} };
102
- auto iter = _jobContextReg.find (key);
103
- if (iter == _jobContextReg.end ()) {
104
- TF_CODING_ERROR (" Export job context %s does not exists" , jobContext.c_str ());
105
- return ;
106
- }
106
+ TF_DEBUG (PXRUSDMAYA_REGISTRY).Msg (" Adding export job context %s UI.\n " , jobContext.c_str ());
107
107
108
- // Note: the container for the plugin info is a set so it cannot be modified.
109
- // We need to copy the entry, modify the copy, remove the old entry and
110
- // insert the newly updated entry.
108
+ TfToken key (jobContext);
109
+ ContextInfo newInfo { key };
110
+ newInfo. exportUICallback = uiFct;
111
111
112
- ContextInfo updatedInfo (*iter);
113
- updatedInfo.exportUICallback = uiFct;
114
- UsdMaya_RegistryHelper::AddUnloader ([key]() { _jobContextReg.erase (key); }, fromPython);
115
- _jobContextReg.erase (iter);
116
- _jobContextReg.insert (updatedInfo);
112
+ auto itFound = _jobContextReg.find (newInfo);
113
+ if (itFound == _jobContextReg.end ()) {
114
+ _jobContextReg.insert (newInfo);
115
+ UsdMaya_RegistryHelper::AddUnloader (
116
+ [key]() { _jobContextReg.erase (ContextInfo { key }); }, fromPython);
117
+ } else {
118
+ // Note: the container for the plugin info is a set so it cannot be modified.
119
+ // We need to copy the entry, modify the copy, remove the old entry and
120
+ // insert the newly updated entry.
121
+
122
+ ContextInfo updatedInfo (*itFound);
123
+ updatedInfo.exportUICallback = uiFct;
124
+ _jobContextReg.erase (itFound);
125
+ _jobContextReg.insert (updatedInfo);
126
+ }
117
127
}
118
128
119
129
void UsdMayaJobContextRegistry::RegisterImportJobContext (
@@ -124,9 +134,12 @@ void UsdMayaJobContextRegistry::RegisterImportJobContext(
124
134
bool fromPython)
125
135
{
126
136
TF_DEBUG (PXRUSDMAYA_REGISTRY).Msg (" Registering import job context %s.\n " , jobContext.c_str ());
137
+
127
138
TfToken key (jobContext);
128
- ContextInfo newInfo { key, TfToken (niceName), {}, {}, TfToken (description), enablerFct };
129
- auto itFound = _jobContextReg.find (newInfo);
139
+ ContextInfo newInfo { key, TfToken (niceName), {}, {}, {}, TfToken (description) };
140
+ newInfo.importEnablerCallback = enablerFct;
141
+
142
+ auto itFound = _jobContextReg.find (newInfo);
130
143
if (itFound == _jobContextReg.end ()) {
131
144
_jobContextReg.insert (newInfo);
132
145
UsdMaya_RegistryHelper::AddUnloader (
@@ -136,22 +149,29 @@ void UsdMayaJobContextRegistry::RegisterImportJobContext(
136
149
},
137
150
fromPython);
138
151
} else {
139
- if (!itFound->importEnablerCallback ) {
140
- if (niceName != itFound->niceName ) {
141
- TF_CODING_ERROR (
142
- " Import enabler has differing nice name: %s != %s" ,
143
- niceName.c_str (),
144
- itFound->niceName .GetText ());
145
- }
146
- // Fill the import part:
147
- ContextInfo updatedInfo (*itFound);
148
- updatedInfo.importDescription = TfToken (description);
149
- updatedInfo.importEnablerCallback = enablerFct;
150
- _jobContextReg.erase (updatedInfo);
151
- _jobContextReg.insert (updatedInfo);
152
- } else {
152
+ if (itFound->importEnablerCallback ) {
153
153
TF_CODING_ERROR (" Multiple enablers for import job context %s" , jobContext.c_str ());
154
154
}
155
+
156
+ if (itFound->niceName .size () > 0 && niceName.size () > 0 && niceName != itFound->niceName ) {
157
+ TF_CODING_ERROR (
158
+ " Import enabler has differing nice name: %s != %s" ,
159
+ niceName.c_str (),
160
+ itFound->niceName .GetText ());
161
+ }
162
+
163
+ // Note: the container for the plugin info is a set so it cannot be modified.
164
+ // We need to copy the entry, modify the copy, remove the old entry and
165
+ // insert the newly updated entry.
166
+
167
+ ContextInfo updatedInfo (*itFound);
168
+ if (niceName.size () > 0 )
169
+ updatedInfo.niceName = TfToken (niceName);
170
+ if (description.size () > 0 )
171
+ updatedInfo.importDescription = TfToken (description);
172
+ updatedInfo.importEnablerCallback = enablerFct;
173
+ _jobContextReg.erase (updatedInfo);
174
+ _jobContextReg.insert (updatedInfo);
155
175
}
156
176
}
157
177
@@ -160,22 +180,27 @@ void UsdMayaJobContextRegistry::SetImportOptionsUI(
160
180
UIFn uiFct,
161
181
bool fromPython)
162
182
{
163
- const ContextInfo key { TfToken (jobContext), {}, {}, {}, {}, {} };
164
- auto iter = _jobContextReg.find (key);
165
- if (iter == _jobContextReg.end ()) {
166
- TF_CODING_ERROR (" Import job context %s does not exist" , jobContext.c_str ());
167
- return ;
168
- }
183
+ TF_DEBUG (PXRUSDMAYA_REGISTRY).Msg (" Adding import job context %s UI.\n " , jobContext.c_str ());
169
184
170
- // Note: the container for the plugin info is a set so it cannot be modified.
171
- // We need to copy the entry, modify the copy, remove the old entry and
172
- // insert the newly updated entry.
185
+ TfToken key (jobContext);
186
+ ContextInfo newInfo { key, {}, {}, {}, {}, {}, {}, uiFct };
187
+ newInfo. importUICallback = uiFct;
173
188
174
- ContextInfo updatedInfo (*iter);
175
- updatedInfo.importUICallback = uiFct;
176
- UsdMaya_RegistryHelper::AddUnloader ([key]() { _jobContextReg.erase (key); }, fromPython);
177
- _jobContextReg.erase (iter);
178
- _jobContextReg.insert (updatedInfo);
189
+ auto itFound = _jobContextReg.find (newInfo);
190
+ if (itFound == _jobContextReg.end ()) {
191
+ _jobContextReg.insert (newInfo);
192
+ UsdMaya_RegistryHelper::AddUnloader (
193
+ [key]() { _jobContextReg.erase (ContextInfo { key }); }, fromPython);
194
+ } else {
195
+ // Note: the container for the plugin info is a set so it cannot be modified.
196
+ // We need to copy the entry, modify the copy, remove the old entry and
197
+ // insert the newly updated entry.
198
+
199
+ ContextInfo updatedInfo (*itFound);
200
+ updatedInfo.importUICallback = uiFct;
201
+ _jobContextReg.erase (itFound);
202
+ _jobContextReg.insert (updatedInfo);
203
+ }
179
204
}
180
205
181
206
TfTokenVector UsdMayaJobContextRegistry::_ListJobContexts ()
0 commit comments