Delphi - Copy an object

291 views Asked by At

I have researched so much to find, how to make a copy from an object in firemonkey, I need to make a copy from an object of a type TBluetoothLEDevice, because every time I free the object, I loss the bluetooth connection, so I'd like to copy this object in order to maintain the connection when I free the first object.

The object is not from TPersistent, so I can not use the assign method, I have tried to use the JSON/Marshalling example, but I got an error:

Internal: Type tkPointer is not currently supported

Is there a way to copy this object? Or some idea to point me a way?

1

There are 1 answers

1
David Heffernan On

I'd like to copy this object in order to maintain the connection when I free the first object.

Copying the object won't help. When you free the other object, the connection state will be destroyed and you'll be left with a useless copy of an object, full of stale references.

What you need to do is either keep the connection open, or reconnect. Perhaps you can achieve the former by simpler refraining from destroying the object.

Either way, we'd need to know more details of your goals and code in order to give detailed advice.