From: <ah...@us...> - 2012-10-19 17:18:39
|
Revision: 13462 http://jvcl.svn.sourceforge.net/jvcl/?rev=13462&view=rev Author: ahuser Date: 2012-10-19 17:18:28 +0000 (Fri, 19 Oct 2012) Log Message: ----------- Much better fix for the bookmark access violation Modified Paths: -------------- trunk/jvcl/run/JvDBUltimGrid.pas Modified: trunk/jvcl/run/JvDBUltimGrid.pas =================================================================== --- trunk/jvcl/run/JvDBUltimGrid.pas 2012-10-19 12:53:31 UTC (rev 13461) +++ trunk/jvcl/run/JvDBUltimGrid.pas 2012-10-19 17:18:28 UTC (rev 13462) @@ -438,15 +438,13 @@ end; FSortOK := False; - if Assigned(DataLink) and DataLink.Active and Assigned(FieldsToSort) then + if Assigned(DataLink) and DataLink.Active and Assigned(FieldsToSort) and + (DataSource.DataSet <> nil) and not (DataSource.DataSet.Eof and DataSource.DataSet.Bof) then begin // Dataset must be in browse mode DSet := DataSource.DataSet; DSet.CheckBrowseMode; - if FRestoreOnSort then - SaveGridPosition; - // Checking of OnUserSort assignment if Assigned(OnUserSort) then SortWith := swUserFunc; @@ -462,6 +460,9 @@ not IsPublishedProp(DSet, cIndexFieldNames) then raise EJVCLDbGridException.CreateRes(@RsEJvDBGridIndexPropertyMissing); + if FRestoreOnSort then + SaveGridPosition; + // Sorting Screen.Cursor := crHourGlass; DSet.DisableControls; @@ -537,7 +538,6 @@ end; end else - if SortWith = swClient then begin // Sort with IndexName @@ -731,20 +731,17 @@ procedure TJvDBUltimGrid.RestoreGridPosition(Mode: TResyncMode = [rmExact, rmCenter]); begin - if FSavedBookmark <> {$IFDEF RTL200_UP}nil{$ELSE}''{$ENDIF RTL200_UP} then + if Assigned(FOnRestoreGridPosition) then begin - if Assigned(FOnRestoreGridPosition) then - begin - if DataLink.DataSet.BookmarkValid(Pointer(FSavedBookmark)) then - GotoBookmarkEx(DataLink.DataSet, Pointer(FSavedBookmark), [rmExact], False); + if (FSavedBookmark <> {$IFDEF RTL200_UP}nil{$ELSE}''{$ENDIF RTL200_UP}) and DataLink.DataSet.BookmarkValid(Pointer(FSavedBookmark)) then + GotoBookmarkEx(DataLink.DataSet, Pointer(FSavedBookmark), [rmExact], False); - DataLink.ActiveRecord := FSavedRowPos; - FOnRestoreGridPosition(Self, Pointer(FSavedBookmark), FSavedRowPos); - end - else - if DataLink.DataSet.BookmarkValid(Pointer(FSavedBookmark)) then - GotoBookmarkEx(DataLink.DataSet, Pointer(FSavedBookmark), Mode, False); - end; + DataLink.ActiveRecord := FSavedRowPos; + FOnRestoreGridPosition(Self, Pointer(FSavedBookmark), FSavedRowPos); + end + else + if (FSavedBookmark <> {$IFDEF RTL200_UP}nil{$ELSE}''{$ENDIF RTL200_UP}) and DataLink.DataSet.BookmarkValid(Pointer(FSavedBookmark)) then + GotoBookmarkEx(DataLink.DataSet, Pointer(FSavedBookmark), Mode, False); end; function TJvDBUltimGrid.PrivateSearch(var ResultCol: Integer; var ResultField: TField; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |