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 » LineEdit, EditFields, DocEdit » DropDate Crash (Application crashes out when selecting date)
DropDate Crash [message #57750] Wed, 08 December 2021 04:50 Go to next message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
Decided to rewrite a little app once again, this time using sqlite and planning on adding more features... I have downloaded the latest stable UPP (15947 as of today) and use this to clean compile before posting. Anyway, I've got a little window to add a record to the larger table:
LAYOUT(NewDrawingLayout, 464, 120)
	ITEM(Upp::DropDate, dpDate, LeftPosZ(8, 104).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtFirst, MaxChars(2).LeftPosZ(128, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtSecond, MaxChars(2).LeftPosZ(172, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtThird, MaxChars(2).LeftPosZ(216, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtFourth, MaxChars(2).LeftPosZ(256, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtFifth, MaxChars(2).LeftPosZ(300, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtSixth, MaxChars(2).LeftPosZ(348, 28).TopPosZ(28, 19))
	ITEM(Upp::EditInt, txtBonus, MaxChars(2).LeftPosZ(420, 28).TopPosZ(28, 19))
	ITEM(Upp::Button, btnAdd, SetLabel(t_("Add New")).LeftPosZ(32, 56).TopPosZ(76, 15))
	ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(364, 56).TopPosZ(76, 15))
END_LAYOUT


And I've created a simple class for it:
class NewDrawing : public WithNewDrawingLayout<TopWindow> {

	public:
				NewDrawing();
		void 	AddNew();
		int		CheckBet(int bet[6], int drawing[7]);
		int		CheckAllBets(int drawing[7]);
};
NewDrawing::NewDrawing()
{
	CtrlLayout(*this, "Lotto Tools by Jim");
	// Button assignments here
	cancel << [=] { Close(); };
	btnAdd << [=] { AddNew(); };
	
	dpDate.SetConvert(DateIntConvert());
}

void NewDrawing::AddNew()
{
	bool doit = false;
	if (IsNull(txtFirst) || IsNull(txtSecond) || IsNull(txtThird) || IsNull(txtFourth) || IsNull(txtFifth) || IsNull(txtSixth) || IsNull(txtBonus))
	{
		Exclamation("Must fill in all values first");
		return;
	}
	// Date betdate = dpDate.GetData();
	doit = (bool)PromptOKCancel("Are you sure you want to add this drawing?");
	if (!doit) Close();
	
	int drawing[7] ={ txtFirst.GetData(), txtSecond.GetData(),
		txtThird.GetData(),txtFourth.GetData(),
		txtFifth.GetData(),txtSixth.GetData(),txtBonus.GetData() 
	};
	SQL * Insert(RESULTS)
		(DRAWDATE,dpDate.GetData())
		(FIRST,drawing[0])
		(SECOND,drawing[1])
		(THIRD,drawing[2])
		(FOURTH,drawing[3])
		(FIFTH,drawing[4])
		(SIXTH,drawing[5])
		(BONUS,drawing[6]);
	CheckAllBets(drawing);
	Close();
}


The convert code is:
Convert& DateIntConvert();

struct DateIntConvertCls : ConvertDate {
    virtual Value Format(const Value& q) const;
    virtual Value Scan(const Value& text) const;
    virtual int Filter(int chr) const;
};
// From sql borrow.cpp example
Value DateIntConvertCls::Format(const Value& q) const
{
    return IsNull(q) ? String() : ::Format(Date( 1970, 1, 1) + (int)q);
}
// Modified from UPP source
Value DateIntConvertCls::Scan(const Value& text) const
{
	const char *s;
	Date date;
	String txt = text;
	if(txt.IsEmpty()) return (Date) Null;
	s = StrToDate(date, txt);
	if(s)
		for(;;) {
			if(IsDigit(*s))
				break;
			if(*s == '\0')
				return date - Date(1970, 1, 1);
			s++;
		}
	return ErrorValue(t_("Invalid date !"));
}

int DateIntConvertCls::Filter(int chr) const
{
    return CharFilterDate(chr);
}

Convert& DateIntConvert()
{
    return Single<DateIntConvertCls>();
}

Using an EditDate, I can compile the program and type in a valid date. I can then save a record, without crashing. I close the program, change the EditDate to DropDate (in layout, all else the same) - and after recompiling, as soon as I go to choose a date the program will crash.

When I step through to the point of selecting the date, I get the error "Thread 1 "LottoTools" received signal SIGABRT, Aborted." as soon as I click on the calendar.

Any ideas? Have I stumbled on a bug? Or am I just goin nuts Wink

Thanks!

[Updated on: Wed, 08 December 2021 05:06]

Report message to a moderator

Re: DropDate Crash [message #57752 is a reply to message #57750] Wed, 08 December 2021 16:37 Go to previous message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
I've written a small test program focusing on drop date and sqlite - can't seem to repeat the crash, so no bug in upp. I'll have to keep tweaking my code till I find it.
Edit: Found that it doesn't like my dateconvert functions... I've been through this before LOL

[Updated on: Wed, 08 December 2021 16:47]

Report message to a moderator

Previous Topic: [BUG] LineEdit text renderer fails to correctly highlight underlined text .
Next Topic: Memory Mapping LineEdit Data
Goto Forum:
  


Current Time: Fri Apr 26 10:51:46 CEST 2024

Total time taken to generate the page: 0.03028 seconds