OSDN Git Service

相対パスで、.\でカレントディレクトリとする書き方を許容するように拡張した。
[gikonavigoeson/gikonavi.git] / MoveHistoryItem.pas
index bbfa6c0..0a984a6 100644 (file)
@@ -56,15 +56,18 @@ implementation
 uses
     GikoSystem;
 
-
 //! \83R\83\93\83X\83g\83\89\83N\83^
 constructor TMoveHistory.Create( max : Integer );
 begin
     inherited Create;
 
     FIndex := 0;
-    
-    SetHistoryMax( GikoSys.Setting.MoveHistorySize );
+    // \82È\82º\82ª\83f\83o\83b\83O\92\86\82ÉGikoSys\82ªnil\82Ì\8e\9e\82ª\82 \82Á\82½???
+    if (GikoSys = nil) then begin
+        SetHistoryMax( max );
+    end else begin
+        SetHistoryMax( GikoSys.Setting.MoveHistorySize );
+    end;
 end;
 //! \88Ú\93®\97\9a\97ð\82Ì\83A\83C\83e\83\80\92Ç\89Á
 function TMoveHistory.pushItem( item: TMoveHistoryItem): Integer;
@@ -102,18 +105,26 @@ end;
 function TMoveHistory.pushItem( item: TBrowserRecord): Integer;
 var
     history : TMoveHistoryItem;
-    doc : OleVariant;
+    doc : IHTMLDocument2;
 begin
     Result := -1;
-    if ( item <> nil ) and ( item.Thread <> nil )
-        and ( item.Browser <> nil) then begin
-        history := TMoveHistoryItem.Create;
-        history.FThreadItem := item.Thread;
-        doc := Idispatch( olevariant(item.Browser.ControlInterface).Document) as IHTMLDocument2;
-        history.ScrollTop := doc.Body.ScrollTop;
+    if not Assigned(item) then
+        Exit;
+    if not Assigned(item.Thread) then
+        Exit;
+    if not Assigned(item.Browser) then
+        Exit;
 
-        Result := pushItem( history );
-    end;
+    doc := item.Browser.ControlInterface.Document as IHTMLDocument2;
+    if not Assigned(doc) then
+        Exit;
+
+    history := TMoveHistoryItem.Create;
+    history.FThreadItem := item.Thread;
+
+    history.ScrollTop := (doc.body as IHTMLElement2).ScrollTop;
+
+    Result := pushItem( history );
 end;
 //! \88ê\82Â\91O\82Ì\97\9a\97ð\83A\83C\83e\83\80\8eæ\93¾
 function TMoveHistory.getPrevItem(item: TBrowserRecord): TMoveHistoryItem;
@@ -176,7 +187,6 @@ initialization
 finalization
        if MoveHisotryManager <> nil then begin
                MoveHisotryManager.clear;
-        MoveHisotryManager.Free;
-               MoveHisotryManager := nil;
+        FreeAndNil(MoveHisotryManager);
        end;
 end.