@@ -489,17 +489,17 @@ private void EntityParentIndexTextBox_TextChanged(object sender, EventArgs e)
489489 if ( CurrentMCEntity != null )
490490 CurrentMCEntity . _Data . parentIndex = pind ;
491491
492- // Re-resolve the Parent entity based on new index
493- if ( CurrentEntity . Parent . Ymap ? . AllEntities != null && pind >= 0 && pind < CurrentEntity . Parent . Ymap . AllEntities . Length )
492+ string parentName = string . Empty ;
493+ var parentEntities = CurrentEntity . Ymap . Parent . AllEntities ;
494+ if ( parentEntities != null && pind >= 0 && pind < parentEntities . Length )
494495 {
495- var newParent = CurrentEntity . Parent . Ymap . AllEntities [ pind ] ;
496- parentEntityTextBox . Text = newParent ? . Name ?? string . Empty ;
497- }
498- else
499- {
500- parentEntityTextBox . Text = string . Empty ;
496+ parentName = parentEntities [ pind ] ? . Name ?? string . Empty ;
501497 }
502498
499+ populatingui = true ;
500+ parentEntityTextBox . Text = parentName ;
501+ populatingui = false ;
502+
503503 ProjectItemChanged ( ) ;
504504 }
505505 }
@@ -816,18 +816,16 @@ private void parentEntityTextBox_TextChanged(object sender, EventArgs e)
816816 {
817817 if ( populatingui ) return ;
818818 if ( CurrentEntity == null ) return ;
819- if ( CurrentEntity . Parent ? . Ymap ? . AllEntities == null ) return ;
820819
821820 string parentName = parentEntityTextBox . Text ? . Trim ( ) ;
822- if ( string . IsNullOrEmpty ( parentName ) )
823- return ;
821+ if ( string . IsNullOrEmpty ( parentName ) ) return ;
824822
825- var entities = CurrentEntity . Parent . Ymap . AllEntities ;
823+ var parentEntities = CurrentEntity . Ymap . Parent . AllEntities ;
826824 int newIndex = - 1 ;
827825
828- for ( int i = 0 ; i < entities . Length ; i ++ )
826+ for ( int i = 0 ; i < parentEntities . Length ; i ++ )
829827 {
830- if ( entities [ i ] ? . Name == parentName )
828+ if ( parentEntities [ i ] ? . Name == parentName )
831829 {
832830 newIndex = i ;
833831 break ;
@@ -843,19 +841,21 @@ private void parentEntityTextBox_TextChanged(object sender, EventArgs e)
843841 if ( CurrentMCEntity != null )
844842 CurrentMCEntity . _Data . parentIndex = newIndex ;
845843
844+ populatingui = true ;
846845 EntityParentIndexTextBox . Text = newIndex . ToString ( ) ;
846+ populatingui = false ;
847847
848848 ProjectItemChanged ( ) ;
849849 }
850850 }
851851 }
852852 private void SetupParentEntityAutoComplete ( )
853853 {
854- if ( CurrentEntity ? . Parent ? . Ymap ? . AllEntities == null ) return ;
854+ if ( CurrentEntity ? . Ymap ? . Parent ? . AllEntities == null ) return ;
855855
856856 var autoComplete = new AutoCompleteStringCollection ( ) ;
857857
858- foreach ( var entity in CurrentEntity . Parent . Ymap . AllEntities )
858+ foreach ( var entity in CurrentEntity . Ymap . Parent . AllEntities )
859859 {
860860 if ( ! string . IsNullOrEmpty ( entity ? . Name ) )
861861 {
0 commit comments