[SOLVED] ZoomRect capability suddenly lost lazarus / 55-TAChart ---------------------------------------------------------------------- kegge13 · 2020-06-12 14:42 Two weeks ago I noticed that it was not possible anymore to zoom, using the mouse, in a TAChart plot. As I had notihng changed to plot- related code for weeks I did not understand this. So I went back to a stage of the code two months earlier, removed .res file and the lib directory and checked that zooming worked. Then I could take more recent code (week by week) and still zooming stayed alive. Right up to the most recent version at that moment. Today I had the same thing again. Took the code version of three days ago and zooming worked. Returning to todays code in one step failed (every time deleting the .res file and the lib directory). So again making one day steps I returned to the latest version, getting the zoom capability alive. Is there any explanation? Testing the zoom capability I do not every day normally, as I am working on unrelated topics. I do not know any trick to disable nor enable the zooming. I take complete images of the code, including all my own libraries on almost daily basis. (I know, I should use Git, but he seems not to be quite friendly towards me.) I work in debug mode with a (relatively) small .exe file and a large .dbg file. Thanks for any suggestions ---------------------------------------------------------------------- wp · 2020-06-13 14:22 I've never seen such a behavior. Of course, zooming can be turned off by setting Chart.AllowZoom to false or assigning a TCharToolset component to the chart. But as you wrote you did not do this, at least not intentionally. If you are on Windows you could use the program WinMerge (https://winmerge.org/?lang=en) to find out the pair-wise differences between the same units used by the correct and defective versions (I am sure similar tools exist also for other operating systems). Maybe you get an idea of unintentional changes this way. ---------------------------------------------------------------------- kegge13 · 2020-06-16 10:18 Quote from: wp on June 13, 2020, 04:22:30 pmI've never seen such a behavior. Of course, zooming can be turned off by setting Chart.AllowZoom to false or assigning a TCharToolset component to the chart. But as you wrote you did not do this, at least not intentionally. If you are on Windows you could use the program WinMerge (https://winmerge.org/?lang=en) to find out the pair-wise differences between the same units used by the correct and defective versions (I am sure similar tools exist also for other operating systems). Maybe you get an idea of unintentional changes this way. Of course my starting point for the quest was the AllowZoom variable. It is nowhere used in the unit that holds my user interface. Today I added one last menu item and added a lot of comments, which switches on/off the linking of the right axis labels to the left axis based grid. Closed Lazurus, and realised forgot to check on the zooming capability. Reopened, pressed F9: no zooming. So I went back to my snapshot of 8 days ago, removed project.res file and lib directory, openend Lazarus, pressed Shift-F9, F9 and voila, zooming present again. Then I repeated this for the snapshot 6 days ago. As this also went well, I started replacing newer files on a file by file and day by day basis without closing Lazarus. Per day the user interface unit was replaced as last element. Each replacement was noted by Lazarus. Just pressing F9 and checking that zooming worked. Right up to the very last changes I made to today. Zooming is now working again, which is essential for my application. Relieved but not quit happy... ---------------------------------------------------------------------- wp · 2020-06-16 12:26 Quote from: kegge13 on June 16, 2020, 12:18:10 pmRelieved but not quit happy... Me not either. So, you are saying that you reverted to an earlier version, restored functionality one by one, and when your most recent version was reached, everything was working fine although you did not change anything else? Strange... Are you sure that you do not write to arrays beyond the reserved dimensions? Sometime people begin the indexes of dynamic arrays at 1 and write beyond the last item. Is it always necessary to delete the .res file and .lib directory? Wouldn't it be enough to simply do a clean rebuild of the project ("Run" > "Build") or to rebuild also common LCL files ("Run" > "Clean up and Build") without reverting to an older version? ---------------------------------------------------------------------- kegge13 · 2020-06-16 13:04 Quote from: wp on June 16, 2020, 02:26:33 pmSo, you are saying that you reverted to an earlier version, restored functionality one by one, and when your most recent version was reached, everything was working fine although you did not change anything else? Strange... Are you sure that you do not write to arrays beyond the reserved dimensions? Sometime people begin the indexes of dynamic arrays at 1 and write beyond the last item. Is it always necessary to delete the .res file and .lib directory? Wouldn't it be enough to simply do a clean rebuild of the project ("Run" > "Build") or to rebuild also common LCL files ("Run" > "Clean up and Build") without reverting to an older version? Indeed I could restore to the latest version every time without losing zoom if I did it step-by-step. I am and always was very keen on memory leaks, boundary problems and the lot of it. It was stable code in D7 and still is in Lazarus. Only the user interface had to be rebuild due to TAChart. A lot of code was reviewed; bugs were found; all of them were also tested in D7. If zooming works at the start it stays working whatever I do with any data set. I do not know if I need to remove old compiled stuff and the res file. It has become a kind of religion... ---------------------------------------------------------------------- wp · 2020-06-16 14:01 Quote from: kegge13 on June 16, 2020, 03:04:45 pmI do not know if I need to remove old compiled stuff and the res file. It has become a kind of religion... I am asking because doing a clean recompilation is some kind of "normal" operation which is required from time to time when changes are too big. However, this is noticed normally during compilation, not as no-longer-working program features. ---------------------------------------------------------------------- kegge13 · 2020-06-17 15:58 Today I ran into other not understood behavior which was not there yesterday. While staying in Lazarus with a trusted snapshot and from there I started replacing files per day. This was seen by Lazarus, asking permission for reload. I pressed F9 and the problem was not solved. When I set a breakpoint I found out that the breakpoint (and probably that part of code) was completely ignored. Closing and reopening did not solve it. So I used Shift-F9 for a rebuild and then both the breakpoint and the underlying code came to live, resoving the noticed problem too. Very strange. ---------------------------------------------------------------------- wp · 2020-06-17 16:35 No, not strange. That's normal when changes in the code base are "too large". With F9 you only compile the modified units. Sometimes the IDE fails to detect that there are changes and does not compile units which should be compiled. With Shift-F9 ("Build") you delete all compiled units of your project and thus force the IDE to recompile everything. Sometimes it is even required to recompile the units of the libraries on which the project depends ("Clean up and build"). A Shift+F9 is required, for example, when changes are made to resource files because these are not detected by the IDE. And I am not 100% sure, but I think that aslo changes in include files are not considered for recompilation when you only press F9. ---------------------------------------------------------------------- kegge13 · 2020-06-17 17:30 Just now I stumbled upon the real problem I had introduced to disable the zooming. It is the used statement in the project.lpr file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms,   tachartlazaruspkg, lazcontrols,    {<- do not remove these....}  {my forms:} WellForm, KlemLogo; Removing tachartlazaruspkg and lazcontrols will compile without any problems but introduces clearly problems; to me the most noticable was the lost zooming. ---------------------------------------------------------------------- wp · 2020-06-17 20:25 Thanks for this note. I can reproduce the issue, and I understand it. The problem is that TAChart has been designed by its initial developers in a way to keep the many units as much separated as possible. The main TChart component "knows" that zooming exists and how to react on a zoom command, but it does "not know" the way zooming is implemented - this occurs in unit TATools. Unit TATools has initialization code in which the built-in zooming and panning tools are created for TChart. So, in order to take advantage of the built-in zoom/pan the unit TATools must be used by the project. Because there may be situations when zooming/panning is not needed and the related code should not be linked, it is good that these tasks are separted. However, this is not the common case, and in the TAChart package options, the checkbox "Add package unit to uses section" is marked by default. This adds unit TAChartLazarusPck in which all TAChart units are "used" and thus linked to the project (the user still can remove this unit if this feature is not needed), among them TATools, and this is the reason why the built-in zooming works by default. Since you removed the package unit from the project file the unit TATools is not linked any more, and built-in zooming stops working. Simply add TATools to the "uses" clause of one of your files, even if you do not use anything from that unit explicitly, and its initialization code will make zooming work again. This all sounds a bit complicated (it is...), and maybe it should be changed. But I have the smell of a lot of work in my nose if I'd touch anything in this context...