One thing I am always afraid of here since you are passing objects around is memory leaks from dangling objects, so within your function call, if you are creating objects, make sure you destroy them ...