Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5961)
+++ /CKEditor/trunk/CHANGES.html	(revision 5962)
@@ -74,4 +74,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/5766">#5766</a> : Config entry "ignoreEmptyParagraph" should only remove one single empty paragraph in document.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/5931">#5931</a> : Unable to apply inline style because of nested elements with same style name.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/6083">#6083</a> : Dialog close sometimes cause collapsed editor selection before the insertion.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/6427">#6427</a> : Ukrainian;</li>
Index: /CKEditor/trunk/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 5961)
+++ /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 5962)
@@ -134,5 +134,8 @@
 								if ( savedRange )
 								{
-									if ( restoreEnabled )
+									// Range restored here might invalidate the DOM structure thus break up
+									// the locked selection, give it up. (#6083)
+									var lockedSelection = doc.getCustomData( 'cke_locked_selection' );
+									if ( restoreEnabled && !lockedSelection )
 									{
 										// Well not break because of this.
