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 » AddColumn(0, ...) crashes
AddColumn(0, ...) crashes [message #41247] Mon, 18 November 2013 15:57 Go to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Hello unodgs

Now calling GridCtrl::AddColumn(const char *name, int size, bool idx) with name = 0 will crash the program as it calls ToLower(name).

The reason is that AddColumn() calls ToLower(), that calls FromUtf8(), that calls utf8len(), that calls strlen, and strlen(NULL) raises an exception.

Could you prevent it?

It is added in Redmine here.


Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41425 is a reply to message #41247] Mon, 16 December 2013 05:18 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Yes this affects me too. Will need to work around it for now. Important lesson for me not to update to the latest nightly build if you're about to do a training session or public demo Smile

Nick

[Updated on: Mon, 16 December 2013 05:19]

Report message to a moderator

Re: AddColumn(0, ...) crashes [message #41427 is a reply to message #41425] Mon, 16 December 2013 11:38 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

Sorry for that Smile I'm gonna fix it soon
Re: AddColumn(0, ...) crashes [message #41430 is a reply to message #41427] Mon, 16 December 2013 14:56 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Hello Daniel

Please check Redmine entry. It add details. For example it affects to InsertColumn() too.


Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41432 is a reply to message #41430] Mon, 16 December 2013 23:57 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 636
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello Daniel,

It seems that GridCtrl doesn't work at all in latest upp versions.

I enclose exemplary screenshot. Perhaps it would help.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Tue, 17 December 2013 00:03]

Report message to a moderator

Re: AddColumn(0, ...) crashes [message #41433 is a reply to message #41432] Tue, 17 December 2013 00:11 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi Klugier,

I think that is a gross overstatement. Perhaps it would be better to just list in what way you have found it not to work.

I am using GridCtrl and beyond the OP bug everything seems fine and I use it in many different ways.

I know that if I was Daniel "doesn't work at all" would make steam come out of my ears.

Cheers,

Nick
Re: AddColumn(0, ...) crashes [message #41438 is a reply to message #41433] Tue, 17 December 2013 09:52 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Hello Klugier

From you screenshot I infer that you have the AddColumn problem.

A simple solution is:

- GridCtrl.cpp, line 1789, to replace
aliases.Add(ToLower(name), ib.id);
with
aliases.Add(name ? ToLower(name) : "", ib.id);

- GridCtrl.cpp, line 1700, to replace
aliases.Add(ToLower(name), id);
with
aliases.Add(name ? ToLower(name) : "", id);

This problem was reported some weeks ago. I would like to see it solved before, mainly because the problem was clearly defined from the beginning.


Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41439 is a reply to message #41438] Tue, 17 December 2013 13:38 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 636
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello Koldo,

Your solution works perfectly. Thank you!

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.
Re: AddColumn(0, ...) crashes [message #41442 is a reply to message #41439] Wed, 18 December 2013 09:07 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Smile

Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41456 is a reply to message #41442] Thu, 19 December 2013 08:29 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Hello

Mirek has solved this in a simple and consequent way, that is to forgive the using of NULL char *. This makes sense in C because for example strlen(NULL) is not permitted.

Now const char *name = NULL is replaced with const char *name = "".

If in your program you do not do things like grid.AddColumn(NULL) you will not have to change anything.


Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41457 is a reply to message #41456] Thu, 19 December 2013 08:51 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
So what do you have to do if you do use AddColumn(NULL) ?
Re: AddColumn(0, ...) crashes [message #41473 is a reply to message #41457] Fri, 20 December 2013 09:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Hello Nick

The compiler will complain and you should have to substitute it with AddColumn() or AddColumn("").


Best regards
Iñaki
Re: AddColumn(0, ...) crashes [message #41662 is a reply to message #41473] Wed, 08 January 2014 11:07 Go to previous message
koldo is currently offline  koldo
Messages: 3028
Registered: August 2008
Ultimate Member
Fixes to be uploaded today:

GridCtrl.h, line 790
	ItemRect& DoAvg(const char *s = "")            	 { sop = SOP_AVG; sopfrm = s; return *this; }
	ItemRect& DoSum(const char *s = "")              { sop = SOP_SUM; sopfrm = s; return *this; }
	ItemRect& DoMin(const char *s = "")              { sop = SOP_MIN; sopfrm = s; return *this; }
	ItemRect& DoMax(const char *s = "")              { sop = SOP_MAX; sopfrm = s; return *this; }
	ItemRect& DoCount(const char *s = "")          	 { sop = SOP_CNT; sopfrm = s; return *this; }
				
GridCtrl.h, line 1247
	AddColumn("", 0, true) 
				 
				 
GridCtrl.cpp, line 1868
	AddColumn("", size, false);	
	
	
DropGrid.h, line 129 
	GridCtrl::ItemRect& AddIndex(const char *name = "");


Best regards
Iñaki
Previous Topic: [BUG & FIX] [GridCtrl] Copy on GridCtrl with no selection will crash a program.
Next Topic: GridCtrl and background color of a row
Goto Forum:
  


Current Time: Wed Nov 13 13:06:45 CET 2019

Total time taken to generate the page: 0.01836 seconds