Re: [Lazarus] Another widget
On 11/03/2015 01:51 AM, Anthony Walter wrote: > > With my last app, a deb package maker > (http://cache.getlazarus.org/images/cpugraph-deb.png) people expressed > interest. I posted the debs and haven't heard anything back, so there's > that. Patience Grasshopper...I'm working out some bugs/kinks in my program (works great in kub14.04, and not so well in kub15.04). When that is done, next on list is to try the deb packager. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
On Tue, 3 Nov 2015 02:40:11 +0100, José Mejutowrote: >El 02/11/2015 a las 20:32, Bo Berglund escribió: > >>> IMHO using lnet or Synapse would be a lot "clearer" than using the >>> overly complex Indy Library. >> I had already looked at Synapse, but it is blocking. >> I did not know about lnet (or INet as it is shown when one searches) >> before but now I have had a look and it seems to fit the bill for me >> since it is event oriented, like I need for this particular task. >> > >I was following your thread from the beginning and or I do not >understand absolutely nothing about your needs or you are focusing the >problem in the opposite way. Let me explain me, I think you had >inherited a GUI app Not really... I had created a GUI program for talking to a data collection instrument via RS232 a long time ago. And to make things cleaner I had packaged all the specific communications functions in a class so the program only needed to call high level methods. The communications protocol is proprietary and binary and rather complex. >which you need to transform in a console one and The task I have to complete is to port the communications classes over to FPC/Lazarus so I can run a cron job for unattended data collection operations. THe controller is a Raspberry Pi2 with ARM7 CPU. And meanwhile the communications channel has switched from RS232 to TCPIP. >this GUI app uses events to coordinate data flows, so in example the app >connects to a server, gets a web page and some event handler process >this data and outputs something to a file. No, there is no web server or file involved at all! The instrument itself is a WiFi access point and it also exposes the internal serial communications line (which still exists internally) on a TCP port (like 2001 or similar). So I need to use a TCP client component for the connection instead of using a serial comm component. But the serial component is embedded in the communications class and it is built on incoming data being made available via an OnReceive event. So in order to make things work I need to replace that serial comm component with a TCP component that receives data in the same way as the serial one does. >event handler also updates information on screen (AKA TListView, ...) Now, this is the original topic of this thread since I discovered that the comm class also has helper methods to display received data on GUI components like TListView etc and so did not compile in Lazarus. THe helpers will not be called at all in the console case but by just being there and referencing TListView etc they stopped the compile until I was told to add LCL to the project dependencies. And when I did so the compilation worked and this thread should have been closed, but unfortunately it continued but changed topic to event driven network TCP communications... > >That's fine, but my question is why you need event sockets ? Because I want to change the serial comm to TCP comm in the existing code that is entirely event based for data reception. See above. > Code example follows... Well, if I had the opportunity and time to go ahead and rewrite the whole thing I might do it differently and maybe use your suggestions. But that is not an option given the size of the involved units... Right now I am just happy that Mark pointed me towards LNet, which is a TCP comm suite using the event model. It seems like this will be a solution for me. Initial testing -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
On Mon, 02 Nov 2015 20:32:40 +0100, Bo Berglundwrote: >On Mon, 02 Nov 2015 10:24:54 +0100, Michael Schnell > wrote: > >>On 10/31/2015 07:28 PM, Mark Morgan Lloyd wrote: >>> Alternatively look at the lnet code that comes with FPC, ... > >I did not know about lnet before but now I have had a look and it >seems to fit the bill for me since it is event oriented, like I need >for this particular task. > >I will make some tests with this before I continue threading Indy. UPDATE: I successfully made a test console application using the lnet TLTcp class and it works like my previous test using Indy and a thread, except I don't have to go through the hassle of threading myself to fire off the receive data event. So again: Mark and Michael: Thank you very much for your input and making me look at LNet! It seems to be an easier way forward for my project! -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
I answered in a new thread "Thread-to-Mainthread signalizing", as we are getting too far off-topic. -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
On Tue, 03 Nov 2015 12:03:38 +0100, Michael Schnellwrote: >For the record: > >I verified that with the gtk2 (Linux) Widget type, "PostMessage()" uses >a different Event Queue ("TGTKMessageQueue") than "TThread.Queue()" and >TThread.Synchronize()". Moved discussion to new thread named: "Using event driven components in console application" -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
For the record: I verified that with the gtk2 (Linux) Widget type, "PostMessage()" uses a different Event Queue ("TGTKMessageQueue") than "TThread.Queue()" and TThread.Synchronize()". So for this, calling "CheckSynchronize() will not help. You need to use the appropriate GUI-based Widget type. Application.QueuAsyncCall() uses yet an additional Event Queue. Here using a WidgetType is not strictly necessary, but calling "CheckSynchronize() will not help, either. Here, TApplication provides "RemoveAsyncCalls()" which in a GUI Bases Widget Type is called in "Forms". As a non-GUI Project does not have Forms, RemoveAsyncCalls() needs to be called by a different functionality. -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Using event driven components in console application
I am moving a discussion that is being conducted in a thread named: "Lazarus implementation of TListview etc?" to this new thread since the topic has shifted away from the original This topic has to do with using communications components which fire off "OnReceive" events when data arrives (on a serial line or a TCP network connection) inside a console application. I need to modify an existing Delphi class unit such that a serial port component is replaced with a TCP client component. And it must work in a console (non-GUI) application because it must run unattended via cron. Since the original serial component used a receive event for incoming data the rather big class is geared towards handling incoming data this way. So I need to find a TCP component that is non-blocking and fires off OnReceive events when data arrives. Otherwise I will need to do major rework in the class. Long story winding through Synapse, ssockets and Indy10 finally reached lNet today and initial tests make me think it is going to work. However there has been a number of issues raised as to the suitability of threading in a console application in Lazarus/FPC so rather than having this discussed in a thread seemingly about TListView I now create this new thread. In the old one I asked about creating my own events using a TThread object doing blocking reads on a TIdTCPClient object and making the connection between the two threads via CheckSynchronize() and Synchronize() calls respectively. Michael Schnell wrote: >For the record: > >I verified that with the gtk2 (Linux) Widget type, "PostMessage()" uses >a different Event Queue ("TGTKMessageQueue") than "TThread.Queue()" and >TThread.Synchronize()". > >So for this, calling "CheckSynchronize() will not help. You need to use >the appropriate GUI-based Widget type. > >Application.QueuAsyncCall() uses yet an additional Event Queue. Here >using a WidgetType is not strictly necessary, but calling >"CheckSynchronize() will not help, either. Here, TApplication provides >"RemoveAsyncCalls()" which in a GUI Bases Widget Type is called in >"Forms". As a non-GUI Project does not have Forms, RemoveAsyncCalls() >needs to be called by a different functionality. Others have pointed out that events will not work in a console application because there is no message loop built in. But I have now tested the lNet TCP component created in code inside a console application and it seems to work, at least inside the Lazarus IDE under the debugger. But this is of course in a test appliocation built as a descendant to TCustomApplication and not yet using the Delphi class I need to transform -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Thread-to-Mainthread singallizing
On 11/03/2015 12:41 PM, Mark Morgan Lloyd wrote: Thanks for that, useful. That's going to impact anybody trying to convert code that uses custom Windows messages to pass events around. For Delphi users, it is a common (bad) habit to use PostMessage() for Thread to MainThread signaling. It was necessary pre D7. But as of D7, for this purpose there is TThread.Queue() (which only was documented only as of a later version of Delphi). Unfortunately only the SVN version of the FPC RTL provides TThread.Queue() (implemented some time ago on my request THANKS !!! ), But no officially released version has it yet. A long time ago, I did a testing program that with an arbitrary Widget Type checks the "compileability" and the workability of - TThread.Synchronize - TThread.Queue - PostMessage - PostThreadMessage (AFAIK not implemented in Lazarus Linux) - SendMessage ()Forbidden to be called in a Thread) - Application.QueuAsycCall - Application.QueuAsycCall with additional parameter I separated the business Logic and GUI to prepare it to test the "ActiveNoGui" (to be renamed to "GeneralServiceApplication") Widget Type, I intend to do and provide to be include into Lazarus. (In fact the draft of same does have most of this but still is lacking "PostMessage". I don't think I've used QueueAsyncCall() in the context of a non-GUI program. Where I do find it useful is when converting an interactive non-GUI (i.e. console) program into a Lazarus GUI app: enqueue an async call in the main form's FormCreate() with the payload being e.g. a looping interactive command interpreter which calls Application.ProcessMessages when it's got nothing to do. Yep. As the "Main Loop" of the "GeneralServiceApplication" Widget Type uses the timeout of CheckSynchronize to implement TTimer, it can't call RemoveAsyncCalls(). So I implemented TApplication.QueuAsyncCall() by means of TThread.Queue (using a transfer class with a a would-be "Finalizer" procedure). -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Patch for TTrayIcon on Ubuntu's Unity
Unfortunately I don't have much info about TrayIcons. Is it possible to add this Unity support to LCL? The idea sounds good but the discussion stopped early. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus implementation of TListView etc?
Michael Schnell wrote: For the record: I verified that with the gtk2 (Linux) Widget type, "PostMessage()" uses a different Event Queue ("TGTKMessageQueue") than "TThread.Queue()" and TThread.Synchronize()". So for this, calling "CheckSynchronize() will not help. You need to use the appropriate GUI-based Widget type. Thanks for that, useful. That's going to impact anybody trying to convert code that uses custom Windows messages to pass events around. Application.QueuAsyncCall() uses yet an additional Event Queue. Here using a WidgetType is not strictly necessary, but calling "CheckSynchronize() will not help, either. Here, TApplication provides "RemoveAsyncCalls()" which in a GUI Bases Widget Type is called in "Forms". As a non-GUI Project does not have Forms, RemoveAsyncCalls() needs to be called by a different functionality. I don't think I've used QueueAsyncCall() in the context of a non-GUI program. Where I do find it useful is when converting an interactive non-GUI (i.e. console) program into a Lazarus GUI app: enqueue an async call in the main form's FormCreate() with the payload being e.g. a looping interactive command interpreter which calls Application.ProcessMessages when it's got nothing to do. -- 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] VirtualTreeView, clicking to expand collapse only on works for first column
In a VirtualTreeView I have icons to expand and collapse subnodes (the + and - in a square). When clicking on them with the mouse it only works when the column with these icons is the first (left) column. When I change the main column or when I move the first column to the right (so that it's not the most left one anymore) clicking on these icons does nothing. Is this a known bug? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] External SIGSEGV (random) when assigning TBookmark
El 03/11/15 a las 04:40, Michael Van Canneyt escribió: On Mon, 2 Nov 2015, Leonardo M. Ramé wrote: El 01/11/15 a las 09:25, Leonardo M. Ramé escribió: Hi, I don't use data aware controls too often, but as I'm updating a legacy application I have to use them. ... I finally solved this by getting the value of a primary key, then after TSQLQuery.refresh I do a locate for that key, works like a charm. What I don't get is what's the purpouse of TBookmark, I thought it was made for solving the problem I had. Bookmarks are only valid until the dataset closes. I will add this to the documentation. Michael. Ok, but apart from Closing/Opening or Refresh, is there any other way to reload a dataset without closing it? TSqlQuery.Refresh also loses the Bookmark. Regards, Leonardo. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On Tue, 3 Nov 2015 19:37:04 +0100 Ondrej Pokornywrote: > On 03.11.2015 17:34, Mattias Gaertner wrote: > > codetools use only a simple heuristic to calculate the type of a > > binary operator. > > The function TFindDeclarationTool.CalculateBinaryOperator needs to be > > extended for Alias types (e.g. 'integer' instead of longint) and for > > ranges (e.g. if the operands do not fit into an integer). > > Maybe you are talking about the same, but just to be sure: IMO using > hard-coded alias types is not a good idea (theoretically the user can > redefine them). No, I meant that 'integer' is defined as type integer = longint; For the compiler 'integer' is just an alias for longint. But codetools should use the alias as much as possible instead of the underlying base type. Maybe I should have used 'SizeInt' as an example. SizeInt can be longint or int64. When a function returns SizeInt codetools should declare the variable as SizeInt instead of the current base in order to help creating cross platform code. > Instead the type evaluation should go to the end type > (e.g. from Integer to *longint*) and then the end types should be > compared. The comparison can then be done with a hard-coded table (you > need it only for the basic types, so it is OK and safe) and the type > that wins, will be used as the result type (obviously the originally > used alias). > > E.g.: > > procedure Test; > var >I: Integer; >S: SmallInt; > begin >Res := I + S; > end; > > Something like: > 1.) > I = (Integer -> longint) > S = SmallInt > 2.) > ResultBasicType = Compare(longint, SmallInt) -> longint -> I > 3.) > ResultType = ResultBasicType -> I -> *Integer* That would fail with the following example: var i: SizeInt; j: SmallInt; begin k:=i+j; end; The result should be SizeInt, not Integer. Of course there are some hard coded defaults in codetools. For example "i:=3" can be any integer type. In TP/Delphi/LCL applications "integer" is used so often it is a good default. Same for "String". But what type should "i:=3.0" create? Single, Double, Extended, glFloat? It would be nice if codetools could guess the "usual" type from the surrounding code or if it can be set via an IDE/project/package option. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] External SIGSEGV (random) when assigning TBookmark
On Tue, 3 Nov 2015, Leonardo M. Ramé wrote: El 03/11/15 a las 04:40, Michael Van Canneyt escribió: On Mon, 2 Nov 2015, Leonardo M. Ramé wrote: El 01/11/15 a las 09:25, Leonardo M. Ramé escribió: Hi, I don't use data aware controls too often, but as I'm updating a legacy application I have to use them. ... I finally solved this by getting the value of a primary key, then after TSQLQuery.refresh I do a locate for that key, works like a charm. What I don't get is what's the purpouse of TBookmark, I thought it was made for solving the problem I had. Bookmarks are only valid until the dataset closes. I will add this to the documentation. Michael. Ok, but apart from Closing/Opening or Refresh, is there any other way to reload a dataset without closing it? TSqlQuery.Refresh also loses the Bookmark. No, there is not. Michael.-- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On 03.11.2015 20:26, Mattias Gaertner wrote: procedure Test; >var >I: Integer; >S: SmallInt; >begin >Res := I + S; >end; > >Something like: >1.) >I = (Integer -> longint) >S = SmallInt >2.) >ResultBasicType = Compare(longint, SmallInt) -> longint -> I >3.) >ResultType = ResultBasicType -> I ->*Integer* That would fail with the following example: var i: SizeInt; j: SmallInt; begin k:=i+j; end; The result should be SizeInt, not Integer. No, the result will be SizeInt, because (SizeInt -> LongInt) wins over SmallInt and the result thus will be SizeInt (as the original type alias of /*i*/) and not Integer. A problem could be with such code: var i: SizeInt; j: Integer; begin k:=i+j; end; Because obviously on 32bit SizeInt=longint and Integer=longint, so there won't be a deterministic way which type wins. Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
Thank you for the fix, just tried it on fresh trunk, works! Michael Am 03.11.15 um 17:34 schrieb Mattias Gaertner: On Tue, 3 Nov 2015 17:24:02 +0100 Ondrej Pokornywrote: On 03.11.2015 17:08, Mattias Gaertner wrote: Fixed. How did you find it from the description? I didn't. I tested on OS X. You are a wizard :) Sorry for introducing the bug in my code. But I know how it happened: it was introduced by CodeTools variable completion: procedure TIDECommands.PostponeUpdateEvents; begin FDontExecuteUpdateEventsUntil := GetTickCount64 + 500; end; codetools use only a simple heuristic to calculate the type of a binary operator. The function TFindDeclarationTool.CalculateBinaryOperator needs to be extended for Alias types (e.g. 'integer' instead of longint) and for ranges (e.g. if the operands do not fit into an integer). Should I report it in the bug tracker? Yes. 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] Lazarus in trunk not working after Rev 50151 on MacOSX
On 03.11.2015 17:34, Mattias Gaertner wrote: codetools use only a simple heuristic to calculate the type of a binary operator. The function TFindDeclarationTool.CalculateBinaryOperator needs to be extended for Alias types (e.g. 'integer' instead of longint) and for ranges (e.g. if the operands do not fit into an integer). Maybe you are talking about the same, but just to be sure: IMO using hard-coded alias types is not a good idea (theoretically the user can redefine them). Instead the type evaluation should go to the end type (e.g. from Integer to *longint*) and then the end types should be compared. The comparison can then be done with a hard-coded table (you need it only for the basic types, so it is OK and safe) and the type that wins, will be used as the result type (obviously the originally used alias). E.g.: procedure Test; var I: Integer; S: SmallInt; begin Res := I + S; end; Something like: 1.) I = (Integer -> longint) S = SmallInt 2.) ResultBasicType = Compare(longint, SmallInt) -> longint -> I 3.) ResultType = ResultBasicType -> I -> *Integer* Reported: http://mantis.freepascal.org/view.php?id=28953 Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Using event driven components in console application
On Tue, 3 Nov 2015 14:55:54 +0100, Mattias Gaertnerwrote: > >lnet does not use Post/SendMessage, so it works even with the NoGUI >widgetset. > >You can easily implement your own loop and simply call >Application.ProcessMessages. > Thanks, you mean that Application.Processmessages is available in this console program? I did not know that. And it seems like TCustomApplication does not automatically include it either. I get a error "identifier not found: Application" when I try... But now I have a basic Lazarus IDE usage question: When testing the lnet functions I copied the files from the lNet download (the complete lib directory) to my pi home directory into an lnet dir and set the project path to include this dir. After successfully testing lnet I wanted to actually install it into Lazarus so I extracted the complete zipfile (according to install directions here: http://wiki.lazarus.freepascal.org/lNet#Installation) into my lazarus install dir at /home/pi/development/lazarus/components. Then I went into Lazarus menu Package/Open Package file as instructed on the webpage above and installed the lnet package. When it was all done and Lazarus restarted I removed the project path to the sources I used before and compiled my test project and it worked OK. Then, just to make sure, I right-clicked on the TLTcp type name and selected "Find declaration" and unit lNet opened in the IDE. But this unit is NOT where I expected it to be! Instead of in the Lazarus component directory it shows to be located in: /usr/local/fpc/source/utils/fppkg/lnet How did this happen? Seems like there is a copy of lnet in this location so which is Lazarus using? And how did it get there in the first place? I am running FPC 3.1.1 (svn trunk a couple of week back) and Lazarus 1.5 svn 50059M (don't know what M means) -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Using event driven components in console application
On Tue, 03 Nov 2015 18:20:53 +0100 Bo Berglundwrote: > On Tue, 3 Nov 2015 14:55:54 +0100, Mattias Gaertner > wrote: > > > > >lnet does not use Post/SendMessage, so it works even with the NoGUI > >widgetset. > > > >You can easily implement your own loop and simply call > >Application.ProcessMessages. > > > > Thanks, > you mean that Application.Processmessages is available in this console > program? It is available when you use the NoGUI widgetset. If you don't use it, you have to call CheckSynchronize yourself. > I did not know that. And it seems like TCustomApplication > does not automatically include it either. I get a error "identifier > not found: Application" when I try... > > But now I have a basic Lazarus IDE usage question: > When testing the lnet functions I copied the files from the lNet > download (the complete lib directory) to my pi home directory into an > lnet dir and set the project path to include this dir. AFAIK lnet has Lazarus packages. Use them instead of adding paths manually. > After successfully testing lnet I wanted to actually install it into > Lazarus so I extracted the complete zipfile (according to install > directions here: > http://wiki.lazarus.freepascal.org/lNet#Installation) into my lazarus > install dir at /home/pi/development/lazarus/components. > Then I went into Lazarus menu Package/Open Package file as instructed > on the webpage above and installed the lnet package. > > When it was all done and Lazarus restarted I removed the project path > to the sources I used before and compiled my test project and it > worked OK. ... and (hopefully) added the lnet lpk in the project inspector. > Then, just to make sure, I right-clicked on the TLTcp type name and > selected "Find declaration" and unit lNet opened in the IDE. > > But this unit is NOT where I expected it to be! Instead of in the > Lazarus component directory it shows to be located in: > /usr/local/fpc/source/utils/fppkg/lnet You have two lnet. One installed by fppkg and one manually. Open the right lnet .lpk once (Package / Open Package File). > How did this happen? Seems like there is a copy of lnet in this > location so which is Lazarus using? And how did it get there in the > first place? You used fppkg. > I am running FPC 3.1.1 (svn trunk a couple of week back) and Lazarus > 1.5 svn 50059M (don't know what M means) The M means you have local modifications. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
Probably the best approach is: 1.) Compare base types with the table. 1a.) If they are equal, goto 2. 1b.) If they differ, set winner according to table and go to 3. 2.) Compare aliases with the table, set winner. 3.) Use the original alias of the winner as result. About the table: We need one table for integer and one for floating-point types. The integer table could look like ['int64', 'sizeint', 'integer', 'smallint'] (but with all integer types and probably a good idea to allow the user to modify and enhance it - e.g. a simple TStringList). The winner is the one closest to the left (top - smallest index). Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Using event driven components in console application
On Tue, 3 Nov 2015 18:39:50 +0100, Mattias Gaertnerwrote: >> you mean that Application.Processmessages is available in this console >> program? > >It is available when you use the NoGUI widgetset. How do you change which "widgetset" is used? (I really do not know what you mean by widgetset, but I assume it is some kind of application framework). >> When it was all done and Lazarus restarted I removed the project path >> to the sources I used before and compiled my test project and it >> worked OK. > >... and (hopefully) added the lnet lpk in the project inspector. Did not know I had to do that, so no that was not done before compile... Now done. >You have two lnet. One installed by fppkg and one manually. >Open the right lnet .lpk once (Package / Open Package File). So that means that lnet is actually part of fpc then? In that case I have been doing a superfluous thing when installing lnet in the first place. How can I get rid of the one in my local Lazarus copy? > >You used fppkg. What is fppkg? I do not know about it. Google says it is the FPC packet manager and thet one has to run it, which I don't think I have. >The M means you have local modifications. I guess it's because I installed lnet and had to rebuild Lazarus?? -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] External SIGSEGV (random) when assigning TBookmark
Leonardo M. Ramé wrote: El 03/11/15 a las 04:40, Michael Van Canneyt escribió: On Mon, 2 Nov 2015, Leonardo M. Ramé wrote: El 01/11/15 a las 09:25, Leonardo M. Ramé escribió: Hi, I don't use data aware controls too often, but as I'm updating a legacy application I have to use them. ... I finally solved this by getting the value of a primary key, then after TSQLQuery.refresh I do a locate for that key, works like a charm. What I don't get is what's the purpouse of TBookmark, I thought it was made for solving the problem I had. Bookmarks are only valid until the dataset closes. I will add this to the documentation. Michael. Ok, but apart from Closing/Opening or Refresh, is there any other way to reload a dataset without closing it? TSqlQuery.Refresh also loses the Bookmark. Even if you could reload it, I'd have thought that the only valid way of positioning would be by locating against a column (preferably known to have an index). After all, the content of the table might have had gross changes due to the actions of other users, and potentially the layout might have changed. I find myself moving away from data-aware controls and instead executing queries in a background thread, to try to avoid UI glitches while the backend's doing its stuff. -- 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
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On 03.11.2015 20:34, Ondrej Pokorny wrote: A problem could be with such code: var i: SizeInt; j: Integer; begin k:=i+j; end; Because obviously on 32bit SizeInt=longint and Integer=longint, so there won't be a deterministic way which type wins. But this is a similar issue like the one from this report (check all different IFDEFs for the "biggest" type)... http://bugs.freepascal.org/view.php?id=28317 So probably not to be solved. Otherwise IMO the comparison of base types and using the aliases from the definitions is the cleanest way to do it. What if I use my own aliases that won't be supported by CodeTools or if I redefine the usual aliases (I know, bad idea, but still)? The "compare base types - use aliases" approach will still work. Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On Tue, 3 Nov 2015 20:34:30 +0100 Ondrej Pokornywrote: > On 03.11.2015 20:26, Mattias Gaertner wrote: > >> procedure Test; > >> >var > >> >I: Integer; > >> >S: SmallInt; > >> >begin > >> >Res := I + S; > >> >end; > >> > > >> >Something like: > >> >1.) > >> >I = (Integer -> longint) > >> >S = SmallInt > >> >2.) > >> >ResultBasicType = Compare(longint, SmallInt) -> longint -> I > >> >3.) > >> >ResultType = ResultBasicType -> I ->*Integer* > > That would fail with the following example: > > > > var > >i: SizeInt; > >j: SmallInt; > > begin > >k:=i+j; > > end; > > > > The result should be SizeInt, not Integer. > > No, the result will be SizeInt, because (SizeInt -> LongInt) wins over > SmallInt and the result thus will be SizeInt (as the original type alias > of /*i*/) and not Integer. Good. > A problem could be with such code: > > var >i: SizeInt; >j: Integer; > begin >k:=i+j; > end; > > Because obviously on 32bit SizeInt=longint and Integer=longint, so there > won't be a deterministic way which type wins. Left side wins. It can't be perfect, but it should be deterministic. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On Tue, 3 Nov 2015 21:06:45 +0100 Ondrej Pokornywrote: > Probably the best approach is: > > 1.) Compare base types with the table. > 1a.) If they are equal, goto 2. > 1b.) If they differ, set winner according to table and go to 3. > > 2.) Compare aliases with the table, set winner. > > 3.) Use the original alias of the winner as result. > > About the table: > We need one table for integer and one for floating-point types. > The integer table could look like ['int64', 'sizeint', 'integer', > 'smallint'] (but with all integer types and probably a good idea to > allow the user to modify and enhance it - e.g. a simple TStringList). > The winner is the one closest to the left (top - smallest index). Many libs has such types. I have not counted, but I guess the FPC sources has hundreds of them. Probably some of them conflict each other. So something better than a TStringList should be used. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On 04.11.2015 02:25, Mattias Gaertner wrote: About the table: >We need one table for integer and one for floating-point types. >The integer table could look like ['int64', 'sizeint', 'integer', >'smallint'] (but with all integer types and probably a good idea to >allow the user to modify and enhance it - e.g. a simple TStringList). >The winner is the one closest to the left (top - smallest index). Many libs has such types. I have not counted, but I guess the FPC sources has hundreds of them. Probably some of them conflict each other. So something better than a TStringList should be used. Could you tell which one to use? Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] A big thank you!
On 04.11.2015 08:23, Torsten Bonde Christiansen wrote: Dear Coder of code-completion Today after having updated my trunk Lazarus I started coding and did what I usually do with code completion. I was starting to implement a new OnSomething method and did the normal OnSomething := @OnSomethingMethod and pressed CTRL + SHIFT + C and then this showed up: I cannot count how many times I have been annoyed that the code was autoplaced in the published section. To whoever implemented this feature: THANK YOU! :D It was me. You are welcome ;) Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
Fixed in r50217. On 04.11.2015 02:14, Mattias Gaertner wrote: A problem could be with such code: > >var >i: SizeInt; >j: Integer; >begin >k:=i+j; >end; > >Because obviously on 32bit SizeInt=longint and Integer=longint, so there >won't be a deterministic way which type wins. Left side wins. It can't be perfect, but it should be deterministic. SizeInt always wins - both if it is on left side or right side because it has a higher rank than Integer. So it is now completely deterministic. (Under "not deterministic" I ment that "k:=i+j" and "k:=j+i" return different types, which is the case of "left side wins".) On 04.11.2015 05:42, Ondrej Pokorny wrote: On 04.11.2015 02:25, Mattias Gaertner wrote: About the table: >We need one table for integer and one for floating-point types. >The integer table could look like ['int64', 'sizeint', 'integer', >'smallint'] (but with all integer types and probably a good idea to >allow the user to modify and enhance it - e.g. a simple TStringList). >The winner is the one closest to the left (top - smallest index). Many libs has such types. I have not counted, but I guess the FPC sources has hundreds of them. Probably some of them conflict each other. So something better than a TStringList should be used. Could you tell which one to use? Ok, I used just a simple "array of string". It's not the fastest/best for adding items one-by-one but there are not so many types, so who cares... It can be easily replaced if you don't like it. + I may have not added all predefined types in: function BooleanTypesOrderList: TTypeAliasOrderList; function IntegerTypesOrderList: TTypeAliasOrderList; function RealTypesOrderList: TTypeAliasOrderList; function StringTypesOrderList: TTypeAliasOrderList; you are welcome to extend them. Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] A big thank you!
Dear Coder of code-completion Today after having updated my trunk Lazarus I started coding and did what I usually do with code completion. I was starting to implement a new OnSomething method and did the normal OnSomething := @OnSomethingMethod and pressed CTRL + SHIFT + C and then this showed up: I cannot count how many times I have been annoyed that the code was autoplaced in the published section. To whoever implemented this feature: THANK YOU! :D Regards, Torsten. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Patch for TTrayIcon on Ubuntu's Unity
On 11/03/2015 03:17 PM, Anthony Walter wrote: My patch checks for Unity and KDE desktop. Just remove the KDE check and it should be good to go. By the way I tested on Mint 13 Cinnamon (based on 12.04) and it still works. https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L264 I'll try to implement it in lazarus during weekend. To people with actual SVN commit rights, if this gets add it into the LCL could you remember to add me to the Lazarus contributor lists? Thanks. Sure. zeljko -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Patch for TTrayIcon on Ubuntu's Unity
On Tue, Nov 3, 2015 at 4:37 PM, zeljkowrote: > I'll try to implement it in lazarus during weekend. I promise to test it under various Linux desktop systems. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Patch for TTrayIcon on Ubuntu's Unity
My patch checks for Unity and KDE desktop. Just remove the KDE check and it should be good to go. By the way I tested on Mint 13 Cinnamon (based on 12.04) and it still works. https://github.com/sysrpl/Lazarus.UnityAppIndicators/blob/master/lazarus/lcl/interfaces/gtk2/unitywsctrls.pas#L264 To people with actual SVN commit rights, if this gets add it into the LCL could you remember to add me to the Lazarus contributor lists? Thanks. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On Tue, 3 Nov 2015 11:15:02 +0100 Michael Ringwrote: > Here's the info: > > /usr/local/bin/fpc -i > Free Pascal Compiler version 2.6.4 > > Compiler Date : 2014/02/26 > Compiler CPU Target: i386 > > --- > >LCL_PLATFORM=carbon >CPU_TARGET=i386 >COMPILERSWITCH="--compiler=/usr/local/bin/fpc" > >make clean all CPU_TARGET=$CPU_TARGET LCL_PLATFORM=$LCL_PLATFORM > OPT="-k'-framework' -k'ApplicationServices'" || exit 1 Fixed. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On 03.11.2015 17:08, Mattias Gaertner wrote: Fixed. How did you find it from the description? You are a wizard :) Sorry for introducing the bug in my code. But I know how it happened: it was introduced by CodeTools variable completion: procedure TIDECommands.PostponeUpdateEvents; begin FDontExecuteUpdateEventsUntil := GetTickCount64 + 500; end; if FDontExecuteUpdateEventsUntil is not declared and I complete it with Ctrl+Shift+C it creates an integer variable: procedure TIDECommands.PostponeUpdateEvents; var FDontExecuteUpdateEventsUntil: Integer; begin FDontExecuteUpdateEventsUntil := GetTickCount64 + 500; end; I then moved the FDontExecuteUpdateEventsUntil declaration to the private section without checking the actual type of it. If you complete without the addition, the type is correct: procedure TIDECommands.PostponeUpdateEvents; var FDontExecuteUpdateEventsUntil: QWord; begin FDontExecuteUpdateEventsUntil := GetTickCount64; end; Should I report it in the bug tracker? Ondrej -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Using event driven components in console application
On Tue, 03 Nov 2015 14:21:27 +0100 Bo Berglundwrote: >[...] > >Application.QueuAsyncCall() uses yet an additional Event Queue. Here > >using a WidgetType is not strictly necessary, but calling > >"CheckSynchronize() will not help, either. Here, TApplication provides > >"RemoveAsyncCalls()" which in a GUI Bases Widget Type is called in > >"Forms". As a non-GUI Project does not have Forms, RemoveAsyncCalls() > >needs to be called by a different functionality. > > Others have pointed out that events will not work in a console > application because there is no message loop built in. There are different kinds of message loops. For multithreading Synchronize and Thread.Queue you just need a loop in the main thread that calls CheckSynchronize. A LCL program calls Application.Run, which creates such a loop, processing AsyncCalls, Idle calls and CheckSynchronize. The NoGUI widgetset does that too. The other widgetsets additionally support PostMessage and SendMessage, implementing a more complex message queue. Post/SendMessage require Handles, which the NoGUI widgetset does not have. > But I have now tested the lNet TCP component created in code inside a > console application and it seems to work, at least inside the Lazarus > IDE under the debugger. > But this is of course in a test appliocation built as a descendant to > TCustomApplication and not yet using the Delphi class I need to > transform lnet does not use Post/SendMessage, so it works even with the NoGUI widgetset. You can easily implement your own loop and simply call Application.ProcessMessages. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Patch for TTrayIcon on Ubuntu's Unity
On 11/03/2015 02:22 PM, Juha Manninen wrote: Unfortunately I don't have much info about TrayIcons. Is it possible to add this Unity support to LCL? The idea sounds good but the discussion stopped early. Yes it's possible, but wm recognition should be added...eg maybe you run kde instead of unity on ubuntu, but unity trayicon lib is installed, so it'll load unity trayicon instead of xorg one (afair from looking into sources of that patch). zeljko -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus in trunk not working after Rev 50151 on MacOSX
On Tue, 3 Nov 2015 17:24:02 +0100 Ondrej Pokornywrote: > On 03.11.2015 17:08, Mattias Gaertner wrote: > > Fixed. > > How did you find it from the description? I didn't. I tested on OS X. > You are a wizard :) > Sorry for introducing the bug in my code. But I know how it happened: it > was introduced by CodeTools variable completion: > > procedure TIDECommands.PostponeUpdateEvents; > begin >FDontExecuteUpdateEventsUntil := GetTickCount64 + 500; > end; codetools use only a simple heuristic to calculate the type of a binary operator. The function TFindDeclarationTool.CalculateBinaryOperator needs to be extended for Alias types (e.g. 'integer' instead of longint) and for ranges (e.g. if the operands do not fit into an integer). > Should I report it in the bug tracker? Yes. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus