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 » ArrayCtrl, HeaderCtrl & GridCtrl » [bug] ArrayCtrl removing all rows upon removing only last row
[bug] ArrayCtrl removing all rows upon removing only last row [message #40393] Mon, 29 July 2013 20:51 Go to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
I get ALL ArrayCtrl rows removed if I try to remove ONLY the LAST row, while trying the simple procedure below:

1. Create an ArrayCtrl and populate it with rows;
2. Select LAST row;
3. Remove row via ArrayCtrl::RemoveSelection();

test case for reference:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class App : public TopWindow
{
	typedef App CLASSNAME;
	ArrayCtrl 	array;
	Button		btn;
	
//this will remove all ArrayCtrl rows if last row selected:
	void RemoveArrSel() { array.RemoveSelection(); }

	public:
	App() {		
		array.AddColumn("some data");
		for(int i = 1; i < 51; i++)
			array.Add(FormatIntRoman(i, true));
		
		SetRect(0, 0, 300, 300);
		Add(array.HSizePos().TopPos(0, 170));
		
		btn.SetLabel("remove selected");
		Add(btn.HCenterPos(100).BottomPos(4));
		btn.WhenAction = THISBACK(RemoveArrSel);
	}
};

GUI_APP_MAIN
{
	App().Run();
}

It works fine for all other rows, except for the last one.

Running IDE 6158 on Windows 7.

tks!
Re: [bug] ArrayCtrl removing all rows upon removing only last row [message #40430 is a reply to message #40393] Thu, 01 August 2013 09:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello kropniczki

Without testing your code I suspect RemoveSelection() may call in any way WhenAction so RemoveArrSel() is recursively called until array is empty.

Maybe the simplest way to avoid this is to avoid recursion in RemoveArrSel(), like:

void RemoveArrSel() {  
	static bool inFunction;
	if (inFunction)
		return;
	inFunction = true;
	array.RemoveSelection();
	inFunction = false;
}

Although for sure there will be something smarter Smile.


Best regards
IƱaki
Re: [bug] ArrayCtrl removing all rows upon removing only last row [message #40581 is a reply to message #40393] Sun, 18 August 2013 16:36 Go to previous message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
Fixed, thanks for reporting.

Mirek
Previous Topic: Hand cursor over ArrayCtrl Column
Next Topic: [SMALL BUG] HeaderCtrl - one pixel width white line - artifact
Goto Forum:
  


Current Time: Sun Nov 17 14:26:21 CET 2019

Total time taken to generate the page: 0.02027 seconds