Recent

Author Topic: Undefined Anchor setting  (Read 1664 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Undefined Anchor setting
« on: April 09, 2023, 02:21:46 am »
When you place a component on a form, it often/usually has its left and top anchors set but no component listed as the target of that anchor. And this does not ever seem to cause a problem.

But generally, I am uncomfortable and clarify those settings.

However, in a recently released version of my app, one user has reported four components, three TBitBtn and one TEdit being stretched from top of form (where they should be) right down to the bottom of the form. Making the form unusable. I cannot replicate this in extensive testing, several other people have also tried. The user (on U20.04 and XFCe) sees the problem with GTK2 and Qt5 versions of the app but no other user has reported this problem.

The three TBitBtns are anchored to the bottom of the TEdit and the TEdit has bottom anchoring on but no component specified as the target. In this case, the TEdit was previously anchored to the bottom of a component I removed and forgot to attach it to the replacement component.

The code was compiled remotely on Ubuntu's Launchpad to make a PPA and that required me to use Lazarus 2.2.2 (and FPC322). So, its possibly different from my test builds. But the user tells me the problem went away with a new binary with the undefined anchor fixed (and built with Lazarus Main).

Anyone seen anything like this ?  Are such undefined anchors dangerous ?

David
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Undefined Anchor setting
« Reply #1 on: April 09, 2023, 03:33:13 am »
I would not say "dangerous". Lazarus has powerful anchoring system and this is one of the features.
Simple test:
1) Start a new project and put one button on it. Run it and try to resize form by its borders. As expected, button stays on its place with the same size.
2) Now open the Anchor Editor and set Bottom and Right anchors on without specifying sibling. Run again and resize form. Now button will scale.

This probably happen to your user. Or there is something strange with GTk2 on XFCe.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Undefined Anchor setting
« Reply #2 on: April 09, 2023, 04:19:44 am »
Yes, thanks Blaazen. The trouble is I cannot replicate the user's experience no matter what I do. So, testing it on my system is not guarantee its not going to happen on this other user's system.

I am going through the project, looking for similar "Undefined Anchors" for lack of a better name, I have found two others that this user apparently did not experience problems with !  So, maybe that is not the explanation after all. But I have to explain  small controls that unexpectedly decide to stretch themselves from top to bottom of a form !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Undefined Anchor setting
« Reply #3 on: April 09, 2023, 08:23:20 am »
The problem may not be with anchors per se but with the whole LCL autosizing system, which 99% of the time works well, but occasionally fails spectacularly.
It is so complex that I have never mastered it, but it does appear to have some undiscovered bug(s).
I notice this particularly when trying to arrange layout for complex multi-component forms which I try to create at runtime (or new multi-component controls created at runtime) which are glued together only by anchoring and judicious autosizing.
While this "ought to work", in some cases it simply does not, and the expected behaviour is seen, except for a few corner cases where the layout fails to readjust to what the anchoring "ought" to compel.
I have always abandoned these attempts, and gone a different non-anchoring route to get the behaviour I want. Next time it happens to me I will post an example and see if other minds can detect the flaw either in my application of anchoring, or in the LCL (if that is where the problem really lies).

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Undefined Anchor setting
« Reply #4 on: April 09, 2023, 12:51:40 pm »
Do other targets other than Windows have problems with not clearing memory when asked for?

I say this because it's possible an unidealized chunk of memory is in place.

Also, I've seen many usages of timers to fix issues in code that does not exist in windows and there could be a collision of things happening unexpectedly.

The only true wisdom is knowing you know nothing

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Undefined Anchor setting
« Reply #5 on: April 10, 2023, 01:13:10 am »
Thanks Howard, no, the form in question was built in the IDE designer, minimal run time fiddling after that.

I have had a response back from the user who complained, he now has tested a 'fixed' version, delivered in exactly the same way, via Launchpad PPA and the Lazarus222 and it is working perfectly. The only difference is that that I gave that anchor something to grab hold of.

I think its significant that I did have that anchor attached to a component and removed that component. I think that may produce a different result than dropping something on a form and the default anchors working.  But my attempts to reproduce the problem, even in the original code, have failed completely.

The fact that it was completely reproducible, even between gtk2 and Qt5 but for no one else is challenging.  He is using a particularly high resolution screen ....

Jamie, no timers in the unit concerned. The memory question does not seem applicable.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Joanna

  • Hero Member
  • *****
  • Posts: 1414
Re: Undefined Anchor setting
« Reply #6 on: April 10, 2023, 11:24:18 am »
I’ve done a lot of anchoring and I’ve seen controls stretched from top to bottom before usually from the bottom being anchored to the parent.
I’m curious if you had alignment = altop , that might work for making it at top or there is also constraining the parent to fit what the control height should be. I doubt you want that..

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • I like bugs.
Re: Undefined Anchor setting
« Reply #7 on: April 10, 2023, 11:53:48 am »
The control's parent is used when an anchor control is not defined. Anchoring to a parent's bottom indeed stretches the control downwards. It should happen always and with any OS.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Joanna

  • Hero Member
  • *****
  • Posts: 1414
Re: Undefined Anchor setting
« Reply #8 on: April 11, 2023, 09:56:44 am »
I use alignment:= alclient if I want control to fit the parent.

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Undefined Anchor setting
« Reply #9 on: April 11, 2023, 12:56:04 pm »
alignment or align ?

Anyway, no, I tend to use only Anchors so, baring accidents, I would not set align to anything other than alNone.

A mystery.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018