fixes #4691 Error in the log when add twice the same widget

fixed the issue and pushed the code for review, please check it.