<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 30.11.2021 00:27, Juha Manninen via
      lazarus wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPN1EhDj91XkVJg9S0VgXTYL0Ae+uq98=TnO2MeimCSACtPh3A@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">On Mon, Nov 29, 2021 at 11:14 PM Ondrej Pokorny
            via lazarus <<a
              href="mailto:lazarus@lists.lazarus-ide.org"
              moz-do-not-send="true">lazarus@lists.lazarus-ide.org</a>>
            wrote:<br>
          </div>
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div>
                <div>On 29.11.2021 17:18, Juha Manninen via lazarus
                  wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr">
                          <div dir="ltr">
                            <div dir="ltr">The commit message is not
                              perfect but the committed code is, now
                              that I fully understand the issue.<br>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                <p>That is nonsense. I reverted your change. The code
                  user code is just plain wrong and your change in
                  TFrame doesn't change anything about it.</p>
              </div>
            </blockquote>
            <div>No, the code is valid although not recommended.
              Accessing Canvas outside Paint works with some widgetsets
              and then an exception is wrong.</div>
          </div>
        </div>
      </div>
    </blockquote>
    <p>No, Juha, you don't understand the issue at all.</p>
    <p>Accessing Canvas outside Paint is OK under all widgetsets if done
      correctly. Whenever you access the canvas for text measuring you
      have to make sure you can do so. There are 2 solutions for it:</p>
    <p>1.) Check HandleAllocated and skip the measurements if the handle
      is not allocated. Like here:
<a class="moz-txt-link-freetext" href="https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/6e5e5b67df9d26cd477588a27029c8007d08add2">https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/6e5e5b67df9d26cd477588a27029c8007d08add2</a><br>
    </p>
    <p>- or -</p>
    <p>2.) If you really have to do the measurements and return
      something, create an extra handle for the canvas like in
      TCustomLabel.CalculateSize.</p>
    <p>---</p>
    <p>The LCL's function is not to force creating the canvas when it
      cannot be naturally created with manipulating itself like you did.<br>
    </p>
    <p>Ondrej<br>
    </p>
  </body>
</html>