executeCommandStringResult is causing a crash

executeCommandStringResult is causing a crash

jmreinhart
Advisor Advisor
371 Views
1 Reply
Message 1 of 2

executeCommandStringResult is causing a crash

jmreinhart
Advisor
Advisor

Hi, I'm working on a custom context that makes use of additional keys. I'm picking up those key presses using an eventFilter. But if "echo all commands" is turned and the script editor is open then the tool crashes. It seems to be caused by this bit of code. Looking at the docs it says that this function is "not thread safe" which is a likely culprit, but I'm not sure if there is an alternative way to approach this, since executingOnIdle doesn't give a result. Any ideas?

 

 

 

 

bool testContext::eventFilter(QObject * object, QEvent *event)
{
	MStatus status;
	// Check if the viewport is in-focus
	MString activePanel = MGlobal::executeCommandStringResult("getPanel -withFocus",
		false,
		false,
		&status
	);

	...

}

 

 

 

 

0 Likes
Accepted solutions (1)
372 Views
1 Reply
Reply (1)
Message 2 of 2

jmreinhart
Advisor
Advisor
Accepted solution

In the end it turned out to be easier to use hotkeys to accomplish the desired result. I gave a brief example of how to do this on this post.

 

https://forums.autodesk.com/t5/maya-programming/is-it-possible-to-ignore-hotkeys-in-custom-mpxcontex...