Discussion:
IdEncoderMIME doesn't work when created dynamically
(too old to reply)
Mike Ruskai
2008-06-05 15:18:53 UTC
Permalink
I looked to this for doing base64 encoding, to save a little time doing my own
implementation (or modifying others, which oddly never seem to take and return
strings as arguments).

It works, but only if I create the component at design time, which is a bit of
a hassle with BCB2007 (no Indy tool palette).

If I create it dynamically, it fails to initialize the variable FCodingTable,
which causes an assertion failure on line 390 of TIdCoder3to4.pas.

I can't see why this would happen, but it does in both BCB6 and BCB2007. It
sets FFillChar to "=", and, near as I can tell, it should be setting both
variables in the overridden InitComponent function.

The CodingTable property is read-only, so the component can't be used as is if
it's dynamically allocated.

So I did this, which results in a working dynamically-allocatable component:

class Base64 : public TIdEncoderMIME
{
public:

__fastcall Base64(TComponent *owner)
: TIdEncoderMIME(owner)
{
FCodingTable=GBase64CodeTable;
}
};

I have a solution, therefore, but I'd really like to know why it doesn't work
as is, when my limited understanding of Pascal says it should.
Remy Lebeau (TeamB)
2008-06-05 17:15:44 UTC
Permalink
Post by Mike Ruskai
If I create it dynamically, it fails to initialize the variable FCodingTable,
which causes an assertion failure on line 390 of TIdCoder3to4.pas.
That is a known problem in C++. For whatever reason, the compiler is not
invoking InitComponent() correctly in C++, but does so fine in Delphi. I do
not know why, and do not have a fix yet.


Gambit

Loading...