View Issue Details

IDProjectCategoryView StatusLast Update
0027125LazarusWidgetsetpublic2014-12-04 18:51
ReporterBart BroersmaAssigned ToZeljan Rikalo 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSLinuxOS VersionFedora Core 18
Product Version1.3 (SVN)Product Buildr47069 
Target Version1.2.8Fixed in Version 
Summary0027125: TCustomCalendar.Date is wrong inside OnXXXChanged events on Linux-QT
DescriptionInside the OnMonthChanged, OnYearChanged and OnChange the value of TCalendar.Date is wrong, it contains the old value that was previously selected.
Steps To ReproduceUnzip and build attached sample project.
It creates a TCalendar on the form.
Select 3th of december 2014 as the date.
Click on the arrow of the TCalendar to go to the next month (january 2015)

Expected result:
Calendar.YearChanged : 03-01-15
Calendar.MonthChanged : 03-01-15
Calendar.Change : 03-01-15
//order may differ

Observed result:
Calendar.Change : 03-12-14
Calendar.MonthChanged : 03-12-14
Additional InformationThe events that each WS fires differ.

Start with date = 03-12-2014 (dd-mm-yy, so dec 3th 2014), then goto next month in calendar:

Windows:
TCustomCalendar.LMChanged
  ** FDate : 03-12-14
  ** NewDate: 01-01-15
Calendar.YearChanged : 01-01-15
Calendar.MonthChanged : 01-01-15
Calendar.DayChanged : 01-01-15
Calendar.Change : 01-01-15

So, Windows only ever sends LMChange


GTK2 Linux:
TCustomCalendar.LMMonthChanged
Calendar.MonthChanged : 03-01-15
Calendar.Change : 03-01-15
TCustomCalendar.LMDAYChanged
Calendar.DayChanged : 03-01-15
Calendar.Change : 03-01-15

GTK2 does not send LMYEARChanged nor LMChanged

QT Linux
TCustomCalendar.LMYearChanged
Calendar.YearChanged : 03-12-14 //note: date is old date!!
Calendar.Change : 03-12-14
TCustomCalendar.LMChanged
  ** FDate : 03-12-14
  ** NewDate: 03-12-14
TCustomCalendar.LMMonthChanged
Calendar.MonthChanged : 03-12-14
Calendar.Change : 03-12-14
TCustomCalendar.LMChanged
  ** FDate : 03-12-14
  ** NewDate: 03-12-14

QT does not send LMMonthCanged if you click on a date in a different month, it only sends LMDaychanged in this case.
TagsNo tags attached.
Fixed in Revision47080
LazTarget1.2.8
WidgetsetQT
Attached Files

Relationships

related to 0026852 closedBart Broersma TCalendarDialog date selection failure 

Activities

Bart Broersma

2014-12-03 16:14

developer  

cal.zip (65,164 bytes)

Bart Broersma

2014-12-03 17:00

developer   ~0079599

Changing the order of processing in TQtCalendar.signalCurrentPageChanged fixes the issue, but Iḿ not sure if it will brak something else.

procedure TQtCalendar.signalCurrentPageChanged(p1, p2: Integer); cdecl;
var
  Msg: TLMessage;
  ADate: QDateH;
  HasChanges: Boolean;
begin
  {$IFDEF VerboseQt}
  writeln('TQtCalendar.SignalCurrentPageChanged p1=',p1,' p2=',p2);
  {$ENDIF}
  if InUpdate then
    exit;
  FillChar(Msg{%H-}, SizeOf(Msg), #0);
  HasChanges := (AYear <> p1) or (AMonth <> p2);

//Do this block before delivering the messages instead of after it??

  if HasChanges then
  begin
    ADate := QDate_create();
    try
      QCalendarWidget_selectedDate(QCalendarWidgetH(Widget), ADate);
      QDate_setYMD(ADate, p1, p2, QDate_day(ADate));
      SetSelectedDate(ADate);
    finally
      QDate_destroy(ADate);
    end;
  end;


  if AYear <> p1 then
  begin
    Msg.Msg := LM_YEARCHANGED;
    DeliverMessage(Msg);
    Msg.Msg := LM_CHANGED;
    DeliverMessage(Msg);
  end;

  if AMonth <> p2 then
  begin
    Msg.Msg := LM_MONTHCHANGED;
    DeliverMessage(Msg);
    Msg.Msg := LM_CHANGED;
    DeliverMessage(Msg);
  end;

end;

@Zeljan: can you comment on this?

Zeljan Rikalo

2014-12-03 18:36

developer   ~0079603

I'll try to fix it soon.

Bart Broersma

2014-12-03 20:30

developer   ~0079609

@Zeljan: I started a discussion on devel-ML about simplifying the OnXXXChanged events.

Zeljan Rikalo

2014-12-04 09:12

developer   ~0079624

Please test and close if ok.

Bart Broersma

2014-12-04 18:51

developer   ~0079650

Fixed, thanks.

Issue History

Date Modified Username Field Change
2014-12-03 16:13 Bart Broersma New Issue
2014-12-03 16:13 Bart Broersma Status new => assigned
2014-12-03 16:13 Bart Broersma Assigned To => Zeljan Rikalo
2014-12-03 16:13 Bart Broersma Relationship added related to 0026852
2014-12-03 16:14 Bart Broersma File Added: cal.zip
2014-12-03 17:00 Bart Broersma Note Added: 0079599
2014-12-03 18:18 Bart Broersma LazTarget - => 1.2.8
2014-12-03 18:18 Bart Broersma Widgetset => QT
2014-12-03 18:18 Bart Broersma Target Version => 1.2.8
2014-12-03 18:19 Bart Broersma Description Updated View Revisions
2014-12-03 18:36 Zeljan Rikalo Note Added: 0079603
2014-12-03 20:30 Bart Broersma Note Added: 0079609
2014-12-04 09:12 Zeljan Rikalo Fixed in Revision => 47080
2014-12-04 09:12 Zeljan Rikalo Note Added: 0079624
2014-12-04 09:12 Zeljan Rikalo Status assigned => resolved
2014-12-04 09:12 Zeljan Rikalo Resolution open => fixed
2014-12-04 18:51 Bart Broersma Note Added: 0079650
2014-12-04 18:51 Bart Broersma Status resolved => closed