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  |
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 
Thanks!
[Updated on: Wed, 08 December 2021 05:06] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 10 09:21:57 CEST 2025
Total time taken to generate the page: 0.02064 seconds
|