In c++ version, I called qSlicerApplication::application()->mrmlScene()->StartState(vtkMRMLScene::BatchProcessState) before adding the new node. If I comment out this line, everything works just fine.
So can anyone gives an advice about how or when should I use the State feature?
After you create a new displayable node programmatically it is your responsibility to add display node as well. The easiest way for creating the display node and associate it with the markup node is to call CreateDefaultDisplayNodes() method.
Use it if you manipulate at least 10-20 nodes. Starting/ending batch processing state is quite costly (rebuilds scene models in all node selector GUI widgets, etc.), so it is only worth activating it if you save a lot of time by not ignoring scene updates during the batch process state.