I haven't had a test, but I guess move this line here is incorrect. 
If the root case is what you described, how about moving it before `self.stackedbar.refreshUI();`?