Reputation: 185
Can I use a MProgressWindow
inside MPxNode::compute
method? My plug-in implementation doesn't reserve MProgressWindow
even when it is not being used by another process.
MStatus Node::compute(const MPlug & plug, MDataBlock & data) {
if (!MProgressWindow::reserve())
return MS::kFailure;
MProgressWindow::setTitle(this->typeName);
MProgressWindow::setInterruptable(true);
MProgressWindow::setProgressRange(0, 100);
MProgressWindow::setProgressStatus("Initializing: 0%");
MProgressWindow::setProgress(0);
MProgressWindow::startProgress();
// Some expensive operation.
// If the user presses ESC key, this ends the progress window and returns failure.
MProgressWindow::endProgress();
return MS::kSuccess;
}
Note: When the node is deleted, MProgressWindow
is displayed (strange behavior).
I appreciate any help.
Upvotes: 0
Views: 164
Reputation: 302
Prior to Maya 2016 plugin code runs in the same thread as Maya's UI. This means that whenever your plugin is doing anything Maya's UI is frozen.
In your compute() the MProgressWindow calls are queuing up a bunch of UI actions but they won't be processed until after compute() returns and the thread can hand control back to the UI.
From Maya 2016 onward it gets more complicated. Whether your plugin code runs in the same thread as Maya's UI depends upon the Evaluation Manager and node type settings.
Try using MComputation instead of MProgressWindow. I haven't tried MComputation from within a compute() method so it may not work, but its design is at least better suited to that usage.
Upvotes: 1