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++ Library : Other (not classified elsewhere) » Error in HomeBudget Example?
Re: Error in HomeBudget Example? [message #29235 is a reply to message #29234] Tue, 12 October 2010 14:53 Go to previous messageGo to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

[quote title=mr_ped wrote on Tue, 12 October 2010 08:03]Ok I was finally able to repeat it too. Mr Ped fix is correct, however I would write it a little bit different:
void HomeBudget::UpdateValue()
{
	if(money.IsEmpty())
		return;
		
	try
	{
		SQL & Select(DEFVALUE).From(CATEGORIES).Where(ID == money.Get(CAT_ID));
		Value v = SQL.Fetch() ? SQL[0] : Value(0);
		money.Set(VALUE, v);
		money.Set(PM, GetCategorySign());
	}
	catch(SqlExc &e)
	{
		Exclamation("[* " + DeQtfLf(e) + "]");
	}
}

The second bug fix. Replace RemoveGroup with this code:
void HomeBudget::RemoveGroup()
{
	if(categories.IsEmpty())
	{
		SQL & Delete(GROUPS).Where(ID == groups(ID));
		
		if(groups.GetCount() == 1)
			categories.Disable();
	}
	else
	{
		PromptOK(t_("You can't remove this group. It is not empty."));
		groups.CancelRemove();
	}
}

I'll push changes to the main repo in the evening. Thank you both!

@Mr.Ped - Get was never supposed to be safe. IMO retrieving value from not existing row doesn't make sense and grid should crash. Returning Null (or any other value) could lead to errors that are hard to find.

[Updated on: Tue, 12 October 2010 15:08]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [FIXED]Case bug in X11Wnd.cpp
Next Topic: problem with fprintf
Goto Forum:
  


Current Time: Sat Apr 27 01:30:14 CEST 2024

Total time taken to generate the page: 0.08266 seconds