1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-28 12:02:15 -05:00

Merge branch 'mem-clean' of https://github.com/Dgby714/Simba into dgby/mem-clean

This commit is contained in:
Merlijn Wajer 2011-06-29 18:06:34 +02:00
commit 15149eb62e
4 changed files with 29 additions and 13 deletions

View File

@ -58,10 +58,15 @@ end;
destructor TExtensionManager.Destroy; destructor TExtensionManager.Destroy;
var var
i: Integer; I, C: Integer;
begin begin
for i := 0 to Extensions.Count - 1 do C := Extensions.Count - 1;
TExtension(Extensions.Items[i]).Free; for I := 0 to C do
begin
TExtension(Extensions.Items[I]).Settings.Free;
TExtension(Extensions.Items[I]).Free;
end;
Extensions.Free; Extensions.Free;
inherited Destroy; inherited Destroy;
end; end;

View File

@ -329,6 +329,7 @@ begin
FreeScript; FreeScript;
if Assigned(PSInstance) then if Assigned(PSInstance) then
FreeAndNil(PSInstance); FreeAndNil(PSInstance);
Script.Free;
inherited; inherited;
end; end;

View File

@ -1648,26 +1648,30 @@ begin
Thread.Client.IOManager.SetTarget(Selector.LastPick); Thread.Client.IOManager.SetTarget(Selector.LastPick);
loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true'); loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true');
// Copy our current fonts
if not assigned(Self.OCR_Fonts) and loadFontsOnScriptStart and DirectoryExists(fontPath) then if (loadFontsOnScriptStart) then
begin begin
Self.OCR_Fonts := TMOCR.Create(Thread.Client); if ((not (Assigned(OCR_Fonts))) and DirectoryExists(fontPath)) then
begin
OCR_Fonts := TMOCR.Create(Thread.Client);
OCR_Fonts.InitTOCR(fontPath); OCR_Fonts.InitTOCR(fontPath);
Thread.Client.MOCR.Fonts := OCR_Fonts.Fonts end;
end else
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then if (Assigned(OCR_Fonts)) then
Thread.Client.MOCR.Fonts := OCR_Fonts.Fonts; Thread.Client.MOCR.Fonts := OCR_Fonts.Fonts;
end;
{ {
We pass the entire settings to the script; it will then create a Sandbox We pass the entire settings to the script; it will then create a Sandbox
for settings that are exported to the script. This way we can access all for settings that are exported to the script. This way we can access all
the settings from the PSTHread, and scripts can only access limited the settings from the PSThread, and scripts can only access limited
resources. Hopefully this won't cause any form / thread related problems? resources. Hopefully this won't cause any form / thread related problems?
(Settings doesn't use the Settings form, iirc) (Settings doesn't use the Settings form, iirc)
Well, it was like this previously as well, we just passed a sandbox to it Well, it was like this previously as well, we just passed a sandbox to it
directly, but the sandbox still called Settings. directly, but the sandbox still called Settings.
} }
Thread.SetSettings(SettingsForm.Settings, SimbaSettingsFile); Thread.SetSettings(SettingsForm.Settings, SimbaSettingsFile);
Thread.OpenConnectionEvent:=@ThreadOpenConnectionEvent; Thread.OpenConnectionEvent:=@ThreadOpenConnectionEvent;
Thread.WriteFileEvent:=@ThreadWriteFileEvent; Thread.WriteFileEvent:=@ThreadWriteFileEvent;
Thread.OpenFileEvent:=@ThreadOpenFileEvent; Thread.OpenFileEvent:=@ThreadOpenFileEvent;
@ -2501,6 +2505,10 @@ begin
{ Free the plugins } { Free the plugins }
PluginsGlob.Free; PluginsGlob.Free;
{ Free Fonts }
if (Assigned(OCR_Fonts)) then
OCR_Fonts.Free;
SetLength(DebugStream, 0); SetLength(DebugStream, 0);
DebugCriticalSection.Free; DebugCriticalSection.Free;
@ -3122,7 +3130,6 @@ begin
if Assigned(self.OCR_Fonts) then if Assigned(self.OCR_Fonts) then
self.OCR_Fonts.Free; self.OCR_Fonts.Free;
FormWriteln('Freeing the current fonts. Creating new ones now'); FormWriteln('Freeing the current fonts. Creating new ones now');
// XXX: Can this cause problems when running scripts?
Self.OCR_Fonts := TMOCR.Create(nil); Self.OCR_Fonts := TMOCR.Create(nil);
OCR_Fonts.InitTOCR(fontPath); OCR_Fonts.InitTOCR(fontPath);
end; end;

View File

@ -176,12 +176,15 @@ end;
{ Get the current pointer to our list of Fonts } { Get the current pointer to our list of Fonts }
function TMOCR.GetFonts:TMFonts; function TMOCR.GetFonts:TMFonts;
begin begin
Exit(Self.FFonts); Result := Self.FFonts;
end; end;
{ Set new Fonts. We set it to a Copy of NewFonts } { Set new Fonts. We set it to a Copy of NewFonts }
procedure TMOCR.SetFonts(const NewFonts: TMFonts); procedure TMOCR.SetFonts(const NewFonts: TMFonts);
begin begin
if (Self.FFonts <> nil) then
Self.FFonts.Free;
Self.FFonts := NewFonts.Copy(Self.Client); Self.FFonts := NewFonts.Copy(Self.Client);
end; end;