pcbnew.LoadBoard() then pcbnew.Refresh()

I’m trying to build a plugin where I need to replace components of a given board into the actually displayed board.

If I load a board using pcbnew.LoadBoard() then execute pcbnew.Refresh() the app crashes with a segfault (sometimes it passes).

Any idea why?

LoadBoard() is for standalone scripting, when you are running a plugin use pcbnew.GetBoard()