Re: [fpc-pascal] postgres3 async notify mem leak

2007-06-30 Thread Brad Campbell

Brad Campbell wrote:

G'day all,

I'm using Postgres 8.1 and have async notifies working nicely based on 
select(). The problem is each time I get a notify I leak memory. I've 
commented out the PQfreemem call and find exactly the same size leak 
(tested over 10,000 notifies). I assume from that I'm doing something 
very wrong but I just can't see where. I've been unable to find much in 
the way of examples out there so I assume I'm doing something wrong.




And I'm not, the leak is in the LCL TLabel component. Sorry for the noise.

Brad
--
"Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so." -- Douglas Adams
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] html link extractor

2007-06-30 Thread Andrew Haines
Andrew Haines wrote:
> Is there a unit somewhere that can extract links from html pages? I want
> to be able to recursively add pages to a chm archive.
> 

I think this from l505 will work:
http://lists.freepascal.org/lists/fpc-announce/2007-February/000536.html

but are there any units that come default with fpc that can do this?

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] html link extractor

2007-06-30 Thread Andrew Haines
Is there a unit somewhere that can extract links from html pages? I want
to be able to recursively add pages to a chm archive.

Thanks,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpCanvas and FPColor property

2007-06-30 Thread Michael Van Canneyt


On Sat, 30 Jun 2007, Graeme Geldenhuys wrote:

> Hi,
> 
> TFPCustomFont has a property as follows:
>  property FPColor : TFPColor ...
> 
> TFPColor is a record compared to Lazarus and Delphi's Color property
> being TColor with is a LongWord.
> If I persist a Form containing a Label to a .dfm or .lfm or whatever
> extension I want to use.  Will the internal TWriter of TComponent be
> able to write a TFPColor property to file?  Or will I have to do some
> magic in TWriter or implement a Color: TColor property in my
> components?
> 
> If the later is needed, why doesn't TFPCustomCanvas implement the
> FPColor property  like Lazarus and Delphi using TColor (LongWord).

Because TFPColor is a 64-bit structure. When it was implemented, streaming
was not a consideration. 

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Documentation for sqldb - further adventures

2007-06-30 Thread Joost van der Sluis
On Fri, 2007-06-29 at 18:35 +1000, John & Marg Sunderland wrote:
> Following earlier advice, I constructed a simple query ("select * from  
> organiser.durn_type"), set readonly to false and tried to modify some 
> data and commit it.
> 
> (At this point I should note that I am doing this from Lazarus 0.9.22 
> with the supplied fpc, 2.0.4 I think, and I am connecting to a 
> postgresql database v 8.1.4 on the same PC, all on Window$ XP SP2.)
> 
> I have no trouble opening the query to display the data in a grid 
> (readonly or not) but when I made some changes, ApplyUpdates gave a 
> database error: "syntax error at end of input at character 127"
> 
> I first tried to trace the execution (in Lazarus IDE), but was unable to 
> trace into the db or sqldb modules - "step into" ran straight to the 
> error, and breakpoints reverted to disabled once the program started to 
> run.  Is there any reason why this should be so ?  Or should I ask in 
> the Lazarus discussion areas ?
> 
> I then turned on lots of logging in Postgresql, and found the error to 
> be in a statement:
> 
> 2007-06-29 14:50:16 LOG:  statement: EXECUTE   [PREPARE:  
> prepare prepst0  as select * from organiser.durn_type]
> 2007-06-29 14:50:16 LOG:  statement: prepare prepst1  as
>   select ic.relname as indexname,  tc.relname as tablename, ia.attname, 
> i.indisprimary, i.indisunique
>   from pg_attribute ta, pg_attribute ia, pg_class tc, pg_class ic, 
> pg_index i
>   where( (i.indrelid = tc.oid)
> and (ta.attrelid = tc.oid)
> and (ia.attrelid = i.indexrelid)
> and (ic.oid = i.indexrelid)
> and (ta.attnum = i.indkey[ia.attnum-1])
> and (upper(tc.relname)='ORGANISER.DURN_TYPE') )
>   order by ic.relname;

This is what is done: to create the update/insert/delete it has to
detect what the primary-key is. For that purpose it executes the second
query. 

> I then ran this in an SQL window from PGAdmin, and it ran, but returned 
> no rows.  I then removed the "ORGANISER." prefix on the table, and it 
> ran and returned some rows.  So, I removed the "organiser." schema 
> prefix from the query in Lazarus, and it worked ! YAY!   (The database 
> connection is logged in under that schema)  However, is it definite that 
> I can't specify a schema prefix for a table, and should I document it as 
> a restriction, or does this rate as a bug ? I can see from looking at 
> the pg_class table that the above query is never going to work - relname 
> is a simple object name, and the schema owner is an oid in another column.

To fix this the table-name has to be parsed, to get the schema-prefix.
That's not an easy fix.
You could solve this problem by setting the update/delete/insert queries
yourself. (and set parsesql to false) Or you could set
UsePrimaryKeyAsKey to false, and set updatemode to UpWhereAll, or make
one of the fields a key-field.

> Finally, as this table is a set of fairly static codes, and therefore 
> would not expect a lot of activity, I tried constructing the editing 
> form as a dialog box, only applying updates and committing when the OK 
> button is used to close the form, and canceling the updates otherwise.  
> Again, does this make sense ?  It seems to work, except that:  When I 
> only change one line and close (committing) it is fine, but if I change 
> several lines, I get a string of errors "EVariantTypeCastError - could 
> not convert type (String) to type (OleStr). "  It still works - I 
> presume the errors must be "handled", as I do not see them if I run from 
> outside the IDE, and the changes are saved.

This is normal. The exception is handled, but the debugger used by
lazarus, can't detect this. But check that your changes are really
saved. 

Joost

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to analyze a core dump?

2007-06-30 Thread Luca Olivetti

En/na Luca Olivetti ha escrit:

Maybe it's not a good idea to mix c multithreaded libraries and pascal 
code? Any special unit I should use? (I already tried cmem and it made 
no difference).
If I cannot solve it I think I'll have to write a small backend program 
in c that communicates with pascal either through stdin/stdout 
redirection or with a socket.


Well, I actually did that and it works pretty well: I hacked the 
existing linphonec console program to output status codes on stdout, I 
spawn it using a TProcess to read its input and sending it commands.
Everything else in my program is pretty much the same (where before I 
called a linphone routine, now I write to the TProcess input, where 
before I gathered status information from a callback[*] now I read from 
the TProcess output), so I think there's no glaring error in the logic 
of my program, just something "strange" mixing pascal and c code (note 
that I'm still using libusb with no apparent issues).
I'd really like to debug the original problem, since the current 
workaround is too hackish to be published, but, alas, every effort to 
debug it so far has failed.


[*]note that the callbacks were not called at random, but only during a 
specific call to the linphone library, so there are no synchronization 
differences between the library calls and the TProcess polling.


Bye
--
Luca

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] postgres3 async notify mem leak

2007-06-30 Thread Brad Campbell

G'day all,

I'm using Postgres 8.1 and have async notifies working nicely based on select(). The problem is each 
time I get a notify I leak memory. I've commented out the PQfreemem call and find exactly the same 
size leak (tested over 10,000 notifies). I assume from that I'm doing something very wrong but I 
just can't see where. I've been unable to find much in the way of examples out there so I assume I'm 
doing something wrong.


Aside from the memory leak it all works very, very well.
(I'm using this in Lazarus but not using any of the lcl or fcl database components but the postgres3 
unit directly as none of those seem to support PQsocket)


procedure chk_notify;

var
   Notify : PpgNotify;

begin
Notify := PQnotifies(conn);
while Notify <> Nil do
Begin
  PQfreemem(Notify);
  Inc(queue)
  Notify := PQnotifies(conn);
End;
end;

Anybody have any ideas?

Regards,
Brad
--
"Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so." -- Douglas Adams
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fpCanvas and FPColor property

2007-06-30 Thread Graeme Geldenhuys

Hi,

TFPCustomFont has a property as follows:
 property FPColor : TFPColor ...

TFPColor is a record compared to Lazarus and Delphi's Color property
being TColor with is a LongWord.
If I persist a Form containing a Label to a .dfm or .lfm or whatever
extension I want to use.  Will the internal TWriter of TComponent be
able to write a TFPColor property to file?  Or will I have to do some
magic in TWriter or implement a Color: TColor property in my
components?

If the later is needed, why doesn't TFPCustomCanvas implement the
FPColor property  like Lazarus and Delphi using TColor (LongWord).

Regards,
 - Graeme -
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fpcanvas and double buffering support

2007-06-30 Thread Graeme Geldenhuys

Hi,

Does TFPCustomCanvas have any mechanism to help with double buffering support?

What does the ManageResources method do in TFPCustomCanvas?

Graeme.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Documentation for sqldb - further adventures

2007-06-30 Thread John & Marg Sunderland
Following earlier advice, I constructed a simple query ("select * from  
organiser.durn_type"), set readonly to false and tried to modify some 
data and commit it.


(At this point I should note that I am doing this from Lazarus 0.9.22 
with the supplied fpc, 2.0.4 I think, and I am connecting to a 
postgresql database v 8.1.4 on the same PC, all on Window$ XP SP2.)


I have no trouble opening the query to display the data in a grid 
(readonly or not) but when I made some changes, ApplyUpdates gave a 
database error: "syntax error at end of input at character 127"


I first tried to trace the execution (in Lazarus IDE), but was unable to 
trace into the db or sqldb modules - "step into" ran straight to the 
error, and breakpoints reverted to disabled once the program started to 
run.  Is there any reason why this should be so ?  Or should I ask in 
the Lazarus discussion areas ?


I then turned on lots of logging in Postgresql, and found the error to 
be in a statement:


2007-06-29 14:50:16 LOG:  statement: EXECUTE   [PREPARE:  
prepare prepst0  as select * from organiser.durn_type]

2007-06-29 14:50:16 LOG:  statement: prepare prepst1  as
 select ic.relname as indexname,  tc.relname as tablename, ia.attname, 
i.indisprimary, i.indisunique
 from pg_attribute ta, pg_attribute ia, pg_class tc, pg_class ic, 
pg_index i

 where( (i.indrelid = tc.oid)
   and (ta.attrelid = tc.oid)
   and (ia.attrelid = i.indexrelid)
   and (ic.oid = i.indexrelid)
   and (ta.attnum = i.indkey[ia.attnum-1])
   and (upper(tc.relname)='ORGANISER.DURN_TYPE') )
 order by ic.relname;

I then ran this in an SQL window from PGAdmin, and it ran, but returned 
no rows.  I then removed the "ORGANISER." prefix on the table, and it 
ran and returned some rows.  So, I removed the "organiser." schema 
prefix from the query in Lazarus, and it worked ! YAY!   (The database 
connection is logged in under that schema)  However, is it definite that 
I can't specify a schema prefix for a table, and should I document it as 
a restriction, or does this rate as a bug ? I can see from looking at 
the pg_class table that the above query is never going to work - relname 
is a simple object name, and the schema owner is an oid in another column.


Finally, as this table is a set of fairly static codes, and therefore 
would not expect a lot of activity, I tried constructing the editing 
form as a dialog box, only applying updates and committing when the OK 
button is used to close the form, and canceling the updates otherwise.  
Again, does this make sense ?  It seems to work, except that:  When I 
only change one line and close (committing) it is fine, but if I change 
several lines, I get a string of errors "EVariantTypeCastError - could 
not convert type (String) to type (OleStr). "  It still works - I 
presume the errors must be "handled", as I do not see them if I run from 
outside the IDE, and the changes are saved.


thanks for any help,
John
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal