I'm using Delphi and creating the object
FObj := TPXC_Inst.Create(nil);
FObj.Init(LIC_KEY);
It appears that when done all I need to do is call
FObj.Free;
Your help said to make sure to call
FObj.Finalize;
However, if I do in fact close by doing this
FObj.Finalize;
FObj.Free;
Then I get exceptions if I create another FObj and do things like open files.
So it appears that FObj.Finalize is not needed but just FObj.Free; with Delphi.
Can you confirm this?
Thanks.
--Jeff
Is Finalize needed in Delphi?
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
Sasha - PDF-XChange
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Is Finalize needed in Delphi?
Hello jeffp,
Have you tried using Finalize method only without the Free method?
Cheers,
Alex
Have you tried using Finalize method only without the Free method?
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
jeffp
- User
- Posts: 926
- Joined: Wed Sep 30, 2009 6:53 pm
Re: Is Finalize needed in Delphi?
I haven't. But that seems to cut against the way objects should be freed in Delphi. That is, if you create and object you should always free it.
I'll give it a try and let you know.
I'll give it a try and let you know.
-
Sasha - PDF-XChange
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Is Finalize needed in Delphi?
I you're using control multiple times, you must create PXV_Inst ONE time globally and destroy it ONCE after the program end.
As described in this topic:
https://forum.pdf-xchange.com/ ... 125#p98125
Cheers,
Alex
As described in this topic:
https://forum.pdf-xchange.com/ ... 125#p98125
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
jeffp
- User
- Posts: 926
- Joined: Wed Sep 30, 2009 6:53 pm
Re: Is Finalize needed in Delphi?
Ok. I follow, but I don't. Let's start with the simple Delphi example below. The second time I call the GetPageCount example below I get a crash. If I comment out the "Finalize" line, it does not crash on subsequent calls.
I'm trying to write some non-visual procedures that will manipulate some PDF files so I'm not putting any objects on TForms, etc. As such, I'm trying to figure out how these new interfaces work. You talk about creating just one IPXC_Inst interface for the life of the application session. How would that look given I'm using the TPXC_Inst activeX object above. Are you saying just create one Global instance of the TPXC_Inst object? I guess I don't follow exactly what Init and Finalize are doing and how to use them with multiple instances of the TPXC_Inst object.
Any help here would be greatly appreciated as I want to make sure I understand these concepts from the start.
You used to have a resident Delphi expert there, but I forgot his name. Who is that?
Lastly, can you confirm that I'm using the IBitSet properly below.
--Jeff
Code: Select all
function GetPageCount(AFileName: String): Cardinal;
var
ADoc: IPXC_Document;
begin
with TPXC_Inst.Create(nil) do
try
Init(LIC_KEY);
ADoc := OpenDocumentFromFile(PChar(AFileName), nil, nil, 0, 0);
ADoc.Pages.Get_Count(Result);
Finalize; //If I comment this line out there are no crashes on subsequent calls.
finally
Free;
end;
end;
Any help here would be greatly appreciated as I want to make sure I understand these concepts from the start.
You used to have a resident Delphi expert there, but I forgot his name. Who is that?
Lastly, can you confirm that I'm using the IBitSet properly below.
Code: Select all
procedure TPDF_Core.DeletePages(APagesAsCommaText: String);
var
i, APage: Integer;
APageCount: Cardinal;
BS: IBitSet;
AOut: IPXC_UndoRedoData;
begin
if Assigned(FDoc) then
begin
FDoc.Pages.Get_Count(APageCount);
if (APageCount > 1) then
begin
BS := FInstAUX.CreateBitSet(APageCount);
BS.SetSize(APageCount);
with TStringList.Create do
try
CommaText := APagesAsCommaText;
for i := 0 to Count - 1 do
begin
APage := StrToIntDef(Strings[i], 0);
if (APage >= 1) and (APage <= APageCount) then BS.Item[APage - 1] := True;
end;
finally
Free;
end;
FDoc.Pages.DeletePages(BS, nil, AOut);
end;
end;
end;
--Jeff
-
Sasha - PDF-XChange
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Is Finalize needed in Delphi?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ