U++ framework
Do not panic. Ask here before giving up.

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: 3461
Registered: August 2008
Senior Veteran
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: 14291
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: Thu Sep 10 00:11:27 GMT+2 2026

Total time taken to generate the page: 0.00722 seconds