FIX: crash when clear an ordered listbox
This commit is contained in:
		
							parent
							
								
									611d295fc8
								
							
						
					
					
						commit
						4fcd2edd54
					
				@ -943,7 +943,7 @@ namespace nana
 | 
				
			|||||||
					catobj.items.clear();
 | 
										catobj.items.clear();
 | 
				
			||||||
					catobj.sorted.clear();
 | 
										catobj.sorted.clear();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					                /// clear all items in all cat, but not the container of cat self.
 | 
				
			||||||
				void clear()
 | 
									void clear()
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					for(auto & m : list_)
 | 
										for(auto & m : list_)
 | 
				
			||||||
@ -1677,7 +1677,18 @@ namespace nana
 | 
				
			|||||||
				///Translate relative position (position in display) into absolute position (original data order)
 | 
									///Translate relative position (position in display) into absolute position (original data order)
 | 
				
			||||||
				size_type absolute(const index_pair& display_pos) const
 | 
									size_type absolute(const index_pair& display_pos) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return (sorted_index_ == npos ? display_pos.item : _m_at(display_pos.cat)->sorted[display_pos.item]);
 | 
					                    if(sorted_index_ == npos) 
 | 
				
			||||||
 | 
					                        return display_pos.item ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    auto & catobj = *_m_at(display_pos.cat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if(catobj.items.size()==0)
 | 
				
			||||||
 | 
					                       if (display_pos == index_pair{0,0} )
 | 
				
			||||||
 | 
					                            return 0;
 | 
				
			||||||
 | 
					                       else 
 | 
				
			||||||
 | 
					                           return npos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										return catobj.sorted[display_pos.item] ;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				index_pair absolute_pair(const index_pair& display_pos) const
 | 
									index_pair absolute_pair(const index_pair& display_pos) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@ -1687,7 +1698,8 @@ namespace nana
 | 
				
			|||||||
                ///Translate absolute position (original data order) into relative position (position in display)
 | 
					                ///Translate absolute position (original data order) into relative position (position in display)
 | 
				
			||||||
                size_type relative(const index_pair& pos) const
 | 
					                size_type relative(const index_pair& pos) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (sorted_index_ == npos) return pos.item ;
 | 
										if (sorted_index_ == npos) 
 | 
				
			||||||
 | 
					                        return pos.item ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    auto & catobj = *_m_at(pos.cat);
 | 
					                    auto & catobj = *_m_at(pos.cat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1695,6 +1707,10 @@ namespace nana
 | 
				
			|||||||
                        if (pos.item == catobj.sorted[i])
 | 
					                        if (pos.item == catobj.sorted[i])
 | 
				
			||||||
                            return i;
 | 
					                            return i;
 | 
				
			||||||
					 
 | 
										 
 | 
				
			||||||
 | 
					                    if (pos == index_pair{0,0} )
 | 
				
			||||||
 | 
					                        if(catobj.items.size()==0)
 | 
				
			||||||
 | 
					                            return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					return   npos ;
 | 
										return   npos ;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				index_pair relative_pair(const index_pair& pos) const
 | 
									index_pair relative_pair(const index_pair& pos) const
 | 
				
			||||||
@ -1934,7 +1950,12 @@ namespace nana
 | 
				
			|||||||
					else if(number)
 | 
										else if(number)
 | 
				
			||||||
						scroll.offset_y_abs.item = number - 1;
 | 
											scroll.offset_y_abs.item = number - 1;
 | 
				
			||||||
					else
 | 
										else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
						scroll.offset_y_abs.item = (pos_abs.cat > 0 ? npos : 0);
 | 
											scroll.offset_y_abs.item = (pos_abs.cat > 0 ? npos : 0);
 | 
				
			||||||
 | 
					                        scroll.offset_y_dpl = scroll.offset_y_abs ;
 | 
				
			||||||
 | 
					                        return ;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    scroll_y_dpl_refresh() ;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				void scroll_y_rel(const index_pair& pos_rel)
 | 
									void scroll_y_rel(const index_pair& pos_rel)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@ -4025,12 +4046,13 @@ namespace nana
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			auto & ess = _m_ess();
 | 
								auto & ess = _m_ess();
 | 
				
			||||||
			ess.lister.clear(cat);
 | 
								ess.lister.clear(cat);
 | 
				
			||||||
			auto pos = ess.scroll_y_dpl();
 | 
					            //unsort();   // ??
 | 
				
			||||||
			if(pos.cat == cat)
 | 
					
 | 
				
			||||||
			{
 | 
								  // from current display position
 | 
				
			||||||
				pos.item = (pos.cat > 0 ? npos : 0);
 | 
								  // move to the cat self if not in first cat
 | 
				
			||||||
				ess.set_scroll_y_dpl(pos);
 | 
					              // move to first item ?? if in first cat
 | 
				
			||||||
			}
 | 
					            ess.scroll_y_abs(ess.scroll_y_abs()); 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
			ess.update();
 | 
								ess.update();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4038,9 +4060,13 @@ namespace nana
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			auto & ess = _m_ess();
 | 
								auto & ess = _m_ess();
 | 
				
			||||||
			ess.lister.clear();
 | 
								ess.lister.clear();
 | 
				
			||||||
			auto pos = ess.scroll_y_dpl();
 | 
					            unsort();   // apperar to be espected
 | 
				
			||||||
			pos.item = (pos.cat > 0 ? npos : 0);
 | 
					
 | 
				
			||||||
			ess.set_scroll_y_dpl(pos);
 | 
								  // from current display position
 | 
				
			||||||
 | 
								  // move to the cat self if not in first cat
 | 
				
			||||||
 | 
					              // move to first item ?? if in first cat
 | 
				
			||||||
 | 
					            ess.scroll_y_abs(ess.scroll_y_abs()); 
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
			ess.update();
 | 
								ess.update();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user