Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006067 [JEDI VCL] 00 JVCL Components major always 2013-01-19 08:42 2015-09-14 13:20
Reporter tetardd View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.47
Summary 0006067: TJvDateTimePicker causes Exception when using NullDate
Description The following code (with a form with a simple TJvDateTimePicker and a TBUtton) causes an Exception (cannot set the date) when the button is clicked:

**********************************************************

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, JvExComCtrls,
  JvDateTimePicker;

type
  TForm22 = class(TForm)
    id_ExpEndDate: TJvDateTimePicker;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form22: TForm22;

implementation

{$R *.dfm}

procedure TForm22.FormCreate(Sender: TObject);
begin
     id_ExpEndDate.NullText := 'No date selected';
     id_ExpEndDate.NullDate := 0.0;
     id_ExpEndDate.MinDate := Date;
     id_ExpEndDate.DropDownDate := Date;
end;


procedure TForm22.Button1Click(Sender: TObject);
begin
     id_ExpEndDate.Date := id_ExpEndDate.NullDate;
end;

************************************

This is the code that I propose should be changed in TJvDateTimePicker:
function TJvDateTimePicker.MsgSetDateTime(Value: TSystemTime): Boolean;
var
  LNullText: string;
begin
  Result := inherited MsgSetDateTime(Value);
  
  (* Initial code:
     This is wrong because if the VCL's MsgSetDateTime reports an error, we will
      have an exception, and because the VCL's code does not know about
      NullDate, it will report an error.
      
  if FMsgSetDateTimeEmptyNullText then
    LNullText := ''
  else
    LNullText := FNullText;
  CheckNullValue(LNullText, Format, Kind, SystemTimeToDateTime(Value), NullDate);
  *)
  
  // Proposed changes by David Tetard:
  if not Result then
  begin
    if FMsgSetDateTimeEmptyNullText then
      LNullText := ''
    else
      LNullText := FNullText;
    Result := CheckNullValue(LNullText, Format, Kind,
      SystemTimeToDateTime(Value), NullDate);
  end;
end;
Additional Information
Tags No tags attached.
Attached Files ? file icon JvDateTimePicker.pas [^] (13,207 bytes) 2013-01-22 17:27

- Relationships

-  Notes
(0020412)
tetardd (reporter)
2013-01-22 17:28

After some more testing, my solution was not entirely satisfactory. My last attachment is yet another proposed fix (see changed in code by looking for "Tetard").
(0020808)
obones (administrator)
2013-12-13 12:15

This is now fixed in GIT

- Issue History
Date Modified Username Field Change
2013-01-19 08:42 tetardd New Issue
2013-01-22 17:27 tetardd File Added: JvDateTimePicker.pas
2013-01-22 17:28 tetardd Note Added: 0020412
2013-12-13 10:40 obones Status new => acknowledged
2013-12-13 12:15 obones Note Added: 0020808
2013-12-13 12:15 obones Status acknowledged => resolved
2013-12-13 12:15 obones Fixed in Version => Daily / GIT
2013-12-13 12:15 obones Resolution open => fixed
2013-12-13 12:15 obones Assigned To => obones
2015-09-14 13:20 obones Fixed in Version Daily / GIT => 3.48


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker