Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » DropList bug when removing last item
DropList bug when removing last item [message #14788] Fri, 14 March 2008 18:47 Go to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
Hi,

when you remove an item from a DropList it normally selects the first item in the DropList, but if that Item was the last one it won't update the screen, you have to click on the DropList and that it will update itself.

I have attached a test case.

BTW: If I use the Assist++ to view the available methods from the DropList class it doesn't show me the Remove(int i) method.
Re: DropList bug when removing last item [message #14789 is a reply to message #14788] Fri, 14 March 2008 19:29 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
kodos wrote on Fri, 14 March 2008 19:47

Hi,

when you remove an item from a DropList it normally selects the first item in the DropList, but if that Item was the last one it won't update the screen, you have to click on the DropList and that it will update itself.

I have attached a test case.

BTW: If I use the Assist++ to view the available methods from the DropList class it doesn't show me the Remove(int i) method.

Could not reproduce. Everything worked as expected. Could you post U++ version number and build settings.

kodos wrote on Fri, 14 March 2008 19:47

BTW: If I use the Assist++ to view the available methods from the DropList class it doesn't show me the Remove(int i) method.


Yes, you are right. It doesn't appear under "all", but does appear under "DropList".

Re: DropList bug when removing last item [message #14790 is a reply to message #14789] Fri, 14 March 2008 20:02 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
cbpporter wrote on Fri, 14 March 2008 19:29

Could not reproduce. Everything worked as expected. Could you post U++ version number and build settings.



Hm, I'm on Windows XP with latest SVN.
Re: DropList bug when removing last item [message #14791 is a reply to message #14789] Fri, 14 March 2008 20:04 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
Hi. I've tested it under Ubuntu, U++ SVN 182, and indeed DropList isn't updated after removing last item.


cdabbd745f1234c2751ee1f932d1dd75

[Updated on: Fri, 14 March 2008 20:14]

Report message to a moderator

Re: DropList bug when removing last item [message #14804 is a reply to message #14791] Sat, 15 March 2008 15:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Reproduced.

Well, I am not 100% sure what the right behaviour should be here. DropList is explicitely designed to allow having the value not in list. OTOH, the "SetIndex(0)" after removal was already there...

Well, I guess under circumstances, this is the right fix:

void  DropList::Adjust()
{
	int i = FindKey(value);
	if(i < 0)
		if(GetCount())
			SetIndex(0);
		else
			SetData(Null);
}


Mirek
Re: DropList bug when removing last item [message #14810 is a reply to message #14804] Sat, 15 March 2008 15:25 Go to previous messageGo to next message
bytefield is currently offline  bytefield
Messages: 210
Registered: December 2007
Experienced Member
I guess it could be solved also by adding:
	Sync();

in DropList.cpp(line 88) in Remove function
void DropList::Remove(int i)
{
	key.Remove(i);
	list.Remove(i);
	Adjust();
	Sync();
}

Sync-inc seems the right behavior since almost all functions from DropList do that.

PS:Mirek, could you explain if I'm wrong?


cdabbd745f1234c2751ee1f932d1dd75

[Updated on: Sat, 15 March 2008 15:28]

Report message to a moderator

Re: DropList bug when removing last item [message #14811 is a reply to message #14810] Sat, 15 March 2008 15:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
IMO, this is exactly the dilemma we are facing...

What you sugest would make it seem empty, but GetData would return the original value.

Mirek
Re: DropList bug when removing last item [message #14813 is a reply to message #14788] Sat, 15 March 2008 16:20 Go to previous message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
I think the behavior of Mireks patch is right, because when I remove an element from the list, I really want it to be gone Wink .
Previous Topic: Controls & classes design questions
Next Topic: exception failure
Goto Forum:
  


Current Time: Fri Mar 29 09:00:23 CET 2024

Total time taken to generate the page: 0.01520 seconds