iClone crash on callback


https://forum.reallusion.com/Topic499725.aspx
Print Topic | Close Window

By professor_wm - 4 Years Ago
Hi,
starting with python API I think I have to learn a lot. However at once I get iClone to crash. I try to implement some MIDI data reading (for different issues). So I define a MIDI callback function and open the MIDI device. So far so good. Also I know that the callback receives some data, but whenever I try to call any iClone API function it crashes immediately. I assume that the callback is in a different threat and that therefore I get the crash. So the next attempt is to use a callback to a window but I cannot get the hwnd window handle. I know that Qt supports this (xyz.winId()) but I have no idea how this works with the iClone API.
Anyone any idea to one of these problems?

many thanks
By Tesira - 4 Years Ago
hi professor_wm,

have a look at this demo. It dos not crash my computer and gives the mainwindow.
main_window_address = RLPy.RUi.GetMainWindow()
https://wiki.reallusion.com/IC_Python_API:Screenshotting#User_Interface

Tesira
By professor_wm - 4 Years Ago
Hi Tesira,
many thanks for your answer. However according to description this function returns => "
Get the QWidget address for the main window." Which is not the window handle (hwnd). So this is not working.
By Tesira - 4 Years Ago
Well the script dos show the screenshoot of the mainwindow. So it should know the mainwindow. Or look here.
main_rl_dlg.SetParent(RLPy.RUi.GetMainWindow())
https://wiki.reallusion.com/IC_Python_API:RLPy_RIDialog
But I also have problems with crashes of the event handler and the dialog event handler.
So good luck for you.
Tesira
By professor_wm - 4 Years Ago
"RLPy.RUi.GetMainWindow()" does not return the window handle. It returns the lets say Qt window handler or object. So this does not work.
However I found out that xyz.winId() is working and returns the HWND. So the code would be:
mainWindow = wrapInstance(int(RLPy.RUi.GetMainWindow()), QtWidgets.QMainWindow)
mainWindowHWND = mainwindow.winId()
The simple truth is in my code I wrote it wrong ".WinId()" instead of ".winId()" and did not notice it even when checking it.
OMG what a binners mistake I could not believe it when I saw it.
Many thanks again for your answers.

By Tesira - 4 Years Ago
Great to hear. Thanks to you. So I have also learned a few things.
Tesira