From 5514aca70f03aa00dfc4bb284c87f7a2700fc4b1 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 15 Jan 2019 22:14:01 +0000 Subject: [PATCH] tvplanit: Fix sqlite3 and firebird datastores crashing due to non-specified database names. Fix double-click in VpWeekView to use correct date. Fix some compilation issues of demos. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6791 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/datastores/fb/readme.txt | 3 +- .../tvplanit/examples/datastores/fb/unit1.lfm | 54 +++++++++---------- .../datastores/flex/sqlite3/unit1.lfm | 4 -- .../examples/datastores/xml/unit1.lfm | 26 ++++----- components/tvplanit/source/design/vpnabed.pas | 2 +- components/tvplanit/source/vpbaseds.pas | 8 +-- components/tvplanit/source/vpfbds.pas | 2 + components/tvplanit/source/vpsqlite3ds.pas | 3 ++ components/tvplanit/source/vpvcard.pas | 2 +- components/tvplanit/source/vpweekview.pas | 2 +- 10 files changed, 50 insertions(+), 56 deletions(-) diff --git a/components/tvplanit/examples/datastores/fb/readme.txt b/components/tvplanit/examples/datastores/fb/readme.txt index e7d5ad83f..5f073f4fc 100644 --- a/components/tvplanit/examples/datastores/fb/readme.txt +++ b/components/tvplanit/examples/datastores/fb/readme.txt @@ -6,5 +6,4 @@ Login parameters for the created database: password: masterkey NOTE: -The project creates a new database on the fly using above-menitoned login -parameters. +The project creates a new database on the fly using these login parameters. diff --git a/components/tvplanit/examples/datastores/fb/unit1.lfm b/components/tvplanit/examples/datastores/fb/unit1.lfm index f0319553f..6e99fd95a 100644 --- a/components/tvplanit/examples/datastores/fb/unit1.lfm +++ b/components/tvplanit/examples/datastores/fb/unit1.lfm @@ -8,22 +8,22 @@ object Form1: TForm1 ClientWidth = 895 OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '1.6.0.4' + LCLVersion = '2.1.0.0' object Panel1: TPanel Left = 0 - Height = 43 + Height = 33 Top = 0 Width = 895 Align = alTop AutoSize = True BevelOuter = bvNone - ClientHeight = 43 + ClientHeight = 33 ClientWidth = 895 TabOrder = 0 object VpResourceCombo1: TVpResourceCombo AnchorSideLeft.Control = Panel1 Left = 4 - Height = 33 + Height = 23 Top = 5 Width = 208 DataStore = VpFirebirdDatastore1 @@ -36,9 +36,9 @@ object Form1: TForm1 AnchorSideLeft.Control = VpResourceCombo1 AnchorSideLeft.Side = asrBottom Left = 216 - Height = 35 + Height = 25 Top = 4 - Width = 133 + Width = 98 AutoSize = True BorderSpacing.Left = 4 BorderSpacing.Top = 4 @@ -50,10 +50,10 @@ object Form1: TForm1 object BtnEditRes: TButton AnchorSideLeft.Control = BtnNewRes AnchorSideLeft.Side = asrBottom - Left = 353 - Height = 35 + Left = 318 + Height = 25 Top = 4 - Width = 128 + Width = 94 AutoSize = True BorderSpacing.Left = 4 BorderSpacing.Top = 4 @@ -65,8 +65,8 @@ object Form1: TForm1 end object PageControl1: TPageControl Left = 0 - Height = 643 - Top = 43 + Height = 653 + Top = 33 Width = 895 ActivePage = TabSheet1 Align = alClient @@ -74,11 +74,11 @@ object Form1: TForm1 TabOrder = 1 object TabSheet1: TTabSheet Caption = 'Events and tasks' - ClientHeight = 605 + ClientHeight = 625 ClientWidth = 887 object VpDayView1: TVpDayView Left = 0 - Height = 605 + Height = 625 Top = 0 Width = 283 DataStore = VpFirebirdDatastore1 @@ -114,18 +114,18 @@ object Form1: TForm1 end object Panel2: TPanel Left = 288 - Height = 605 + Height = 625 Top = 0 Width = 339 Align = alLeft BevelOuter = bvNone Caption = 'Panel2' - ClientHeight = 605 + ClientHeight = 625 ClientWidth = 339 TabOrder = 1 object VpWeekView1: TVpWeekView Left = 0 - Height = 359 + Height = 379 Top = 0 Width = 339 DataStore = VpFirebirdDatastore1 @@ -153,7 +153,7 @@ object Form1: TForm1 object VpMonthView1: TVpMonthView Left = 0 Height = 241 - Top = 364 + Top = 384 Width = 339 DataStore = VpFirebirdDatastore1 ControlLink = VpControlLink1 @@ -161,7 +161,6 @@ object Form1: TForm1 Align = alBottom TabStop = True TabOrder = 1 - KBNavigation = True DateLabelFormat = 'mmmm yyyy' DayHeadAttributes.Font.Height = -13 DayHeadAttributes.Font.Name = 'Tahoma' @@ -170,6 +169,7 @@ object Form1: TForm1 DrawingStyle = dsFlat EventDayStyle = [] HeadAttributes.Color = clBtnFace + KBNavigation = True OffDayColor = clSilver SelectedDayColor = clRed ShowEvents = True @@ -184,7 +184,7 @@ object Form1: TForm1 Cursor = crVSplit Left = 0 Height = 5 - Top = 359 + Top = 379 Width = 339 Align = alBottom ResizeAnchor = akBottom @@ -192,7 +192,7 @@ object Form1: TForm1 end object VpTaskList1: TVpTaskList Left = 632 - Height = 605 + Height = 625 Top = 0 Width = 255 DataStore = VpFirebirdDatastore1 @@ -220,13 +220,13 @@ object Form1: TForm1 end object Splitter1: TSplitter Left = 627 - Height = 605 + Height = 625 Top = 0 Width = 5 end object Splitter3: TSplitter Left = 283 - Height = 605 + Height = 625 Top = 0 Width = 5 end @@ -280,7 +280,7 @@ object Form1: TForm1 top = 264 end object VpResourceEditDialog1: TVpResourceEditDialog - Version = 'v1.05' + Version = 'v1.12' DataStore = VpFirebirdDatastore1 Options = [] Placement.Position = mpCenter @@ -295,7 +295,6 @@ object Form1: TForm1 Active = False Action = caCommitRetaining Database = IBConnection1 - Options = [] left = 256 top = 120 end @@ -326,7 +325,7 @@ object Form1: TForm1 PlayEventSounds = True Connection = IBConnection1 AutoConnect = False - AutoCreate = True + AutoCreate = False DayBuffer = 31 left = 136 top = 200 @@ -334,15 +333,14 @@ object Form1: TForm1 object IBConnection1: TIBConnection Connected = False LoginPrompt = False - KeepConnection = True + KeepConnection = False Transaction = SQLTransaction1 - Options = [] + CheckTransactionParams = False left = 136 top = 120 end object SQLQuery1: TSQLQuery FieldDefs = <> - Options = [] Params = <> left = 149 top = 512 diff --git a/components/tvplanit/examples/datastores/flex/sqlite3/unit1.lfm b/components/tvplanit/examples/datastores/flex/sqlite3/unit1.lfm index b4f8c12e5..da46c9a4d 100644 --- a/components/tvplanit/examples/datastores/flex/sqlite3/unit1.lfm +++ b/components/tvplanit/examples/datastores/flex/sqlite3/unit1.lfm @@ -576,7 +576,6 @@ object Form1: TForm1 DeleteSQL.Strings = ( '' ) - Options = [sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit] Params = <> left = 136 top = 428 @@ -771,7 +770,6 @@ object Form1: TForm1 DeleteSQL.Strings = ( '' ) - Options = [sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit] Params = <> left = 136 top = 496 @@ -879,7 +877,6 @@ object Form1: TForm1 DeleteSQL.Strings = ( '' ) - Options = [sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit] Params = <> left = 136 top = 560 @@ -950,7 +947,6 @@ object Form1: TForm1 DeleteSQL.Strings = ( '' ) - Options = [sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit] Params = <> left = 136 top = 621 diff --git a/components/tvplanit/examples/datastores/xml/unit1.lfm b/components/tvplanit/examples/datastores/xml/unit1.lfm index 5d243a53a..2335dac13 100644 --- a/components/tvplanit/examples/datastores/xml/unit1.lfm +++ b/components/tvplanit/examples/datastores/xml/unit1.lfm @@ -7,7 +7,7 @@ object Form1: TForm1 ClientHeight = 686 ClientWidth = 980 OnCreate = FormCreate - LCLVersion = '2.1.0.0' + LCLVersion = '2.0.0.3' object Panel1: TPanel Left = 0 Height = 33 @@ -67,9 +67,9 @@ object Form1: TForm1 Height = 653 Top = 33 Width = 980 - ActivePage = TabSheet2 + ActivePage = TabSheet1 Align = alClient - TabIndex = 1 + TabIndex = 0 TabOrder = 1 object TabSheet1: TTabSheet Caption = 'Events and tasks' @@ -283,17 +283,13 @@ object Form1: TForm1 end object VpControlLink1: TVpControlLink DataStore = VpXmlDatastore1 - Printer.BottomMargin = 0 Printer.DayStart = h_08 Printer.DayEnd = h_05 Printer.Granularity = gr30Min - Printer.LeftMargin = 0 Printer.MarginUnits = imAbsolutePixel Printer.PrintFormats = <> - Printer.RightMargin = 0 - Printer.TopMargin = 0 - left = 136 - top = 264 + Left = 136 + Top = 264 end object VpResourceEditDialog1: TVpResourceEditDialog Version = 'v1.12' @@ -304,12 +300,12 @@ object Form1: TForm1 Placement.Left = 10 Placement.Height = 250 Placement.Width = 400 - left = 136 - top = 335 + Left = 136 + Top = 335 end object PopupMenu1: TPopupMenu - left = 129 - top = 527 + Left = 129 + Top = 527 end object VpXmlDatastore1: TVpXmlDatastore CategoryColorMap.Category0.Color = clNavy @@ -338,7 +334,7 @@ object Form1: TForm1 PlayEventSounds = True AutoConnect = True FileName = 'data.xml' - left = 136 - top = 202 + Left = 136 + Top = 202 end end diff --git a/components/tvplanit/source/design/vpnabed.pas b/components/tvplanit/source/design/vpnabed.pas index 53ea848b6..f6b825872 100644 --- a/components/tvplanit/source/design/vpnabed.pas +++ b/components/tvplanit/source/design/vpnabed.pas @@ -143,7 +143,7 @@ implementation uses PropEditUtils, IDEWindowIntf, StrUtils, ImgList, - VpConst, VpMisc; + {%H-}VpConst, VpMisc; const ITEMS_MARGIN = 2; diff --git a/components/tvplanit/source/vpbaseds.pas b/components/tvplanit/source/vpbaseds.pas index eca096991..1946c9fd2 100644 --- a/components/tvplanit/source/vpbaseds.pas +++ b/components/tvplanit/source/vpbaseds.pas @@ -285,10 +285,10 @@ type procedure RefreshTasks; virtual; procedure RefreshResource; virtual; - procedure PurgeResource(Res: TVpResource); virtual; {abstract;} - procedure PurgeEvents(Res: TVpResource); virtual; {abstract;} - procedure PurgeContacts(Res: TVpResource); virtual; {abstract;} - procedure PurgeTasks(Res: TVpResource); virtual; {abstract;} + procedure PurgeResource(Res: TVpResource); virtual; + procedure PurgeEvents(Res: TVpResource); virtual; + procedure PurgeContacts(Res: TVpResource); virtual; + procedure PurgeTasks(Res: TVpResource); virtual; procedure PostEvents; virtual; abstract; procedure PostContacts; virtual; abstract; diff --git a/components/tvplanit/source/vpfbds.pas b/components/tvplanit/source/vpfbds.pas index f99898e35..482d3e986 100644 --- a/components/tvplanit/source/vpfbds.pas +++ b/components/tvplanit/source/vpfbds.pas @@ -580,6 +580,8 @@ procedure TVpFirebirdDatastore.SetConnected(const AValue: Boolean); begin if (AValue = Connected) or (FConnection = nil) or (FConnectLock > 0) then exit; + if (FConnection.DatabaseName = '') then + exit; inc(FConnectLock); if AValue and AutoCreate then diff --git a/components/tvplanit/source/vpsqlite3ds.pas b/components/tvplanit/source/vpsqlite3ds.pas index 95b869a55..de78c0b05 100644 --- a/components/tvplanit/source/vpsqlite3ds.pas +++ b/components/tvplanit/source/vpsqlite3ds.pas @@ -566,6 +566,9 @@ begin if (FConnection = nil) or (FConnection.Transaction = nil) then exit; + if FConnection.DatabaseName = '' then + exit; + if AValue = FConnection.Connected then exit; diff --git a/components/tvplanit/source/vpvcard.pas b/components/tvplanit/source/vpvcard.pas index a12695c72..8f094cb68 100644 --- a/components/tvplanit/source/vpvcard.pas +++ b/components/tvplanit/source/vpvcard.pas @@ -111,7 +111,7 @@ implementation uses StrUtils, DateUtils, - VPBase, VpMisc; + VpMisc; const ITEMS_DELIMITER = ';'; diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 2b7c5cf71..3a0331a6e 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -1038,7 +1038,7 @@ begin else if (DataStore.Resource <> nil) then begin { otherwise, we must want to create a new event } - StartTime := NextFullHour(Now()); + StartTime := NextFullHour(FActiveDate + Time()); // StartTime := trunc(Date) + 0.5; { default to 12:00 noon } EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes } ActiveEvent := DataStore.Resource.Schedule.AddEvent(