Re: [Lazarus] Something goes wrong while streaming nested components

2015-10-26 Thread Kiên Nguyễn Tiến Trung
Thank you.
Vào 18-10-2015 22:11, "Mattias Gaertner"  đã
viết:

> On Sat, 17 Oct 2015 15:18:12 +0700
> Kiên Nguyễn Tiến Trung  wrote:
>
> > I have been successful to save a component to a text file. However, I
> have
> > a problem while reading them back.
> >
> > To illustrate, this is the text file created by saving the components.
> >
> > object Parent1: TParentClass
> >   Child = Child
> >   Value = 54
> >   Str = 'SP'
> >   List.Strings = (
> > 'PV'
> >   )
> >   object Child: TChildClass
> > Value = 85
> > Str = 'WO'
> > List.Strings = (
> >   'QL'
> > )
> >   end
> > end
> >
> > When I load the component Parent1 using this file, properties Value, Str,
> > and List are loaded successfully. *However, the property Child is not
> > loaded.*
>
> Actually it is created and loaded.
>
>
> > It seems that there is a TChildClass object created and then increases
> the
> > ComponentCount of Parent1. But it is not what I want. I want the property
> > Child be loaded instead of creating a new object.
>
> If I remember correctly you need
>
> Child.ComponentStyle:=Child.ComponentStyle+[csSubComponent];
>
>
> Mattias
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Why is AsyncProcess still disabled under Linux I386?

2015-10-14 Thread Kiên Nguyễn Tiến Trung
Today I have just faced a same problem in the following article:

http://lazarus.lazarus.freepascal.narkive.com/dCiCiyW2/tasyncprocess-onterminate-doesn-t-fire

{$IFNDEF DisableAsyncProcess}
{$IFDEF Linux}
{$IFDEF CPUI386}

*{off $DEFINE UseAsyncProcess}*{$ENDIF}
{$ENDIF}
{$ENDIF}

Why is UseAsyncProcess still off by default? It is really annoying.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Prevent from deadlock while writing something large to a pipe

2015-10-09 Thread Kiên Nguyễn Tiến Trung
Thank you. I will try again with multi threading.

2015-10-09 22:10 GMT+07:00 Sven Barth :

> Am 09.10.2015 16:37 schrieb "Kiên Nguyễn Tiến Trung" :
> >
> > I want to send a big amount of data to a child process through pipe.
> However, it is stated in the documentation that writing too much into the
> pipe may cause a deadlock.
>
> That is not necessarily a deadlock. It just blocks until the receiving
> profess is ready to process more input. Of course you should process it's
> output, cause if it can't write into its output anymore it can't normally
> read from its input either ;)
> That said you could write into the Input in a separate thread, this way
> your GUI stays responsive.
>
> Regards,
> Sven
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Prevent from deadlock while writing something large to a pipe

2015-10-09 Thread Kiên Nguyễn Tiến Trung
I want to send a big amount of data to a child process through pipe.
However, it is stated in the documentation that writing too much into the
pipe may cause a deadlock.
TProcess.Input

Input is a stream which is connected to the process' standard input file
handle. Anything written to this stream can be read by the process.

The Input stream is only instantiated when the poUsePipes flag is used in
Options
.

Note that writing to the stream may cause the calling process to be
suspended when the created process is not reading from it's input, or to
cause errors when the process has terminated.

How can I prevent from deadlock?
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Streaming TStringList with associated objects

2015-06-19 Thread Kiên Nguyễn Tiến Trung
I have a TStringList containing some strings. Each strings is associated
with an object typed TPersistent. I realize that, when streaming
TStringList, all of associated objects are ignored.

What I have to do?
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Align/Anchor to widest label

2015-03-25 Thread Kiên Nguyễn Tiến Trung
I prefer setting property Align to alTop. Although it is not so nice, it
brings me a huge advantage. There is no need to set anchors, so it will be
easy while adding/removing components. As a result, designing time will be
reduce considerably. Additionally, you will no longer need to be worry
about the appearance in different linguistic.

It will look like this (http://i.imgur.com/vEhYjP4.png):




2015-03-25 17:20 GMT+07:00 Henry Vermaak :

> On Wed, Mar 25, 2015 at 10:52:01AM +0100, Torsten Bonde Christiansen wrote:
> > Is it possible by using align, anchor, or some third option, to
> > always make the two edits and the drop-down box align with the
> > widest of the three labels.
> >
> > Since these labels will be translated to many languages I cannot
> > assume that the 2nd labels is the widest, hence anchoring the
> > filename edit to that label, and the drop-down and directory edit to
> > the filename edit, will make the controls overlap eachother.
>
> This has been quite a big problem for me, too.  The only solution I've
> found is to use a container, like a frame or a panel, that has the
> ChildSizing property.  Then you can set the ChildSizing.ControlsPerLine
> to 2 and the container will take care of making sure that everything is
> aligned, as long as you add the controls in the correct order, which
> will depend on the ChildSizing.Layout setting.
>
> The pain comes when you need to change the controls, because the child
> sizing works on the order that the controls are added to the container.
> For this reason I usually do this in code.
>
> Henry
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Tutorial: Animating with easings

2015-03-25 Thread Kiên Nguyễn Tiến Trung
Nice! Although I don't need it, it is a good project.

2015-03-24 22:54 GMT+07:00 Anthony Walter :

> I've posted a video of the Linux version:
>
> http://cache.getlazarus.org/video/surface_easing_ubuntu.mp4
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] HEADS UP: FPC 3.0.1 stable branched off.

2015-03-25 Thread Kiên Nguyễn Tiến Trung
When will FPC 3.0.0 be released officially???

2015-03-24 19:26 GMT+07:00 Mark Morgan Lloyd <
markmll.laza...@telemetry.co.uk>:

> zeljko wrote:
>
>> On 01/10/2015 02:39 PM, Mattias Gaertner wrote:
>>
>>> On Sat, 10 Jan 2015 12:49:04 +
>>> Mark Morgan Lloyd  wrote:
>>>
>>>  Mark Morgan Lloyd wrote:

  Lazarus trunk at about 47318 is OK with FPC 2.7.1 29398 on SPARC using
> Debian "Lenny",
>

 Same combination on a PPC Mac raises an exception as below when the IDE
 is told to Tools -> Options.

 TApplication.HandleException Error reading
 ComponentsListView.Items.LazData: Stream read error
 Stack trace:
 $10118410  TREADER__READPROPERTY,  line 1279 of
 /usr/local/src/fpc/fpc-trunk/rtl/objpas/classes/reader.inc

 Apart from that and the blank toolbar issue it appears OK. Does anybody
 want me to get a backtrace and raise a bug?

>>>
>>> TListItems.ReadLazData reads a TLazItemInfo, which is a record:
>>>
>>>TLazItemInfo = record // packing is not needed and not wanted
>>>  ImageIndex: Integer;
>>>  StateIndex: Integer;
>>>  OverlayIndex: Integer;
>>>  SubItemCount: Integer;
>>>end;
>>>
>>> Without "packed" the layout depends on the platform. But the stream
>>> should be streamed the same on all platforms. So it needs "packed".
>>> OTOH someone added a comment that it is not wanted.
>>>
>>> Has someone an idea why "packed" is "is not needed and not wanted"?
>>>
>>
>> Annotate that unit and see who wrote that ?
>>
>
> Now on Mantis as 27719.
>
> --
> Mark Morgan Lloyd
> markMLl .AT. telemetry.co .DOT. uk
>
> [Opinions above are the author's, not those of his employers or colleagues]
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] button need increase height

2015-02-26 Thread Kiên Nguyễn Tiến Trung
Could you show me the value of the property BorderSpacing?

I think that this issue depends on your system.

2015-02-26 19:28 GMT+07:00 FreeMan :

>  fpc r30015 lazarus r48016 osx x64 qt
> Painted square line's height need little bit increase I think
>
> this is TBitBtn, and focused in designtime in IDE, I mean out border and
> square lines is so defferent. and can see, glyph is out of lines.
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] When loading a TComponent from file, method Loaded fired but method Loading not.

2014-12-17 Thread Kiên Nguyễn Tiến Trung
Thank you, I will ask on FPC list.

2014-12-17 15:43 GMT+07:00 Mattias Gaertner :
>
> On Wed, 17 Dec 2014 15:10:34 +0700
> Kiên Nguyễn Tiến Trung  wrote:
>
> > Today I has found this problem. Although it isn't too serious, I strongly
> > think that it is a bug and it should be patched.
>
> TComponent is part of the FCL, but it is not documented.
> "Loading" is not a Delphi method.
> As far as I know it exists to allow implementing your own streaming
> (aka without a TReader).
> It is not a bug.
> I suggest to ask on the FPC list.
>
> Mattias
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] When loading a TComponent from file, method Loaded fired but method Loading not.

2014-12-17 Thread Kiên Nguyễn Tiến Trung
Today I has found this problem. Although it isn't too serious, I strongly
think that it is a bug and it should be patched.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fwd: Need help in streaming components

2014-12-15 Thread Kiên Nguyễn Tiến Trung
I got it!

Thank all of you very much.

2014-12-15 17:49 GMT+07:00 Mattias Gaertner :
>
> On Mon, 15 Dec 2014 07:34:12 -0300
> Glaucos Ginez  wrote:
>
> > Try TObjectList.
>
> That does not support streaming.
>
>
> >[...]
> > > I want my TClass1 can contain many TClass2. It means that number of
> > > TClass2 in TClass1 is not fixed.
> > >
> > > I've tried to use TComponentList, but it does not work. I knew that
> > > TCollection supports streaming, however, TClass1 and TClass2 must be
> > > TComponent.
>
> The trick is overriding some TComponent methods.
>
> TClass1
> procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
> TClass2
> procedure SetParentComponent(Value: TComponent); override;
> function GetParentComponent: TComponent; override;
> function HasParent: Boolean; override;
>
> See for example
> lazarus/examples/designnonlcl/mywidgetset.pas
> class TMyWidget
>
>
> Mattias
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fwd: Need help in streaming components

2014-12-14 Thread Kiên Nguyễn Tiến Trung
Thank you for your respond. I find that my real problem is more complex and
need more help from you.

I want my TClass1 can contain many TClass2. It means that number of TClass2
in TClass1 is not fixed.

I've tried to use TComponentList, but it does not work. I knew that
TCollection supports streaming, however, TClass1 and TClass2 must be
TComponent.

2014-12-15 0:23 GMT+07:00 Howard Page-Clark :
>
> On 14/12/2014 12:23, Kiên Nguyễn Tiến Trung wrote:
>
>>
>> I am trying to streaming. I spent a lot of time but I didn't find the
>> proper solution.
>>
>> I have two classes, TClass1, TClass2. Although the parent of AClass2 is
>> AClass1, AClass2 isn't saved into specified file, only AClass1 is.
>>
>
> AClass1 is not the parent of AClass2. The two classes have no
> relationship, certainly not a hierarchical relationship.
>
> You make AClass1 the *owner* (not the *ancestor*) of AClass2 for that
> single instantiation in your program (i.e. responsible for correctly
> freeing the instance).
>
> However, TClass1 and TClass2 are completely unrelated, and know nothing
> about each other's properties.
> Perhaps you are looking for something like the attached zipped unit1.pas.
>
> Howard
>
>
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Finding the advantage of TAsyncProcess

2014-12-11 Thread Kiên Nguyễn Tiến Trung
I am using TProcess and I am finding some necessary event handlers such as
OnTerminate. That led me to have a look at TAsyncProcess. However, I can't
find any document related to TAsyncProcess. I really want to know more
about this class, especially events OnReadData. Can I use it instead of
TProcess? Why doesn't it have property OnExecute or any thing else similar?

I really appreciate any help you can provide.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TTIGrid crashed after calling ListObject.Add

2014-12-09 Thread Kiên Nguyễn Tiến Trung
It doesn't crash immediately after clicking Button1. In my case, I must
click into the TIGrid, then it crashes.

2014-12-09 19:31 GMT+07:00 Howard Page-Clark :

> On 09/12/2014 10:41, John Landmesser wrote:
>
>> no crash on a 32bit Windows XP with
>>
>
> For me it sometimes crashes, and sometimes does not (Win7 32-bit).
> The problem is not with adding an item to TCollection (which is fine as
> far as I can see), but probably some hard to find bug in the LCL which
> TTIGrid exposes unpredictably.
>
> Howard
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>
>
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus