Tk Source Code

View Ticket
Login
Ticket UUID: cc6c711c1e52998b214ecf4aa5d6a6cf253d8e14
Title: treeview layout issues in 8.6.10 (regression)
Type: Bug Version: 8.6.10
Submitter: bll Created on: 2019-09-13 17:34:35
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-10-28 11:53:27
Resolution: Fixed Closed By: fvogel
    Closed on: 2019-10-28 11:53:27
Description:
Using identical code, the treeview layout on Linux seems to have changed 
somehow in 8.6.10.  Also happens on MacOS.  I don't have an 8.6.10 compiled
for Windows at this time.

Running with 8.6.8, there is no issue.

This also is only happening when I open the treeview in the second tab
of the notebook, in which case, it remains in the bad layout.
If I open the treeview as the first action, then it displays ok thereafter.

I will see if I can replicate this with a small program.
User Comments: fvogel added on 2019-10-28 11:53:27:

Changes triggered by [caacf1f082] now merged into core-8-6-branch and trunk. Closing this now.


fvogel added on 2019-10-27 11:13:56:

Reopening this ticket since I got report that the original fix that this ticket found a regression on, breaks a user application, see [caacf1f082].


fvogel added on 2019-09-18 17:37:38:

>In the recent checkin, at line 1237, a call to ResizeColumns() was added.

This is indeed correct (commit in question is [0e9cbdba9b2bf4c9]), and must trigger your issue.

After more code analysis and looking at how and when the computed slack is used I believe your original fix is correct. I have committed this fix in core-8-6-branch and trunk.

Thanks!


bll added on 2019-09-16 23:30:04:
In the recent checkin, at line 1237, a call to ResizeColumns() was added.

But the call to TtkResizeWidget() when not mapped already calls the resizing
routines (it does end up calling Stretch(), and therefore also one of
ShoveLeft() or ShoveRight(), but I did not map out the entire call stack).

The extra calls to the resizing routines are the origin of the bad width
setting.

I can't duplicate this outside my application.

A better patch is probably:

    if (mask & GEOMETRY_CHANGED) {
        if (!Tk_IsMapped(tv->core.tkwin)) {
            TtkResizeWidget(&tv->core);
        } else {
          RecomputeSlack(tv);
          ResizeColumns(tv, TreeWidth(tv));
        }
        RecomputeSlack(tv);
    }

fvogel added on 2019-09-16 20:27:57:
Hmmm... I'm dubious.

The fact (which I checked) that the ttk test suite passes is only a loose indicator that the proposed change could be correct. The ttk test suite is much less complete than for the rest of Tk.

With the proposed change, the column sizes are recomputed only if the widget is mapped. There would then be a potential for some code requesting the column -width (before the widget is mapped) and getting a different answer with this patch.

Also, are we really sure that ConfigureColumn() will be called after the widget does get mapped? Otherwise there would potentially be erroneous columns widths due to lack of an up-to-date computation.

In a nutshell, I've yet to convince myself that this change is the correct one. Wouldn't it be better to really understand the origin of the wrong column widths in your app? A short demo script would be awesome.

bll added on 2019-09-13 23:18:27:
Possible patch:

Around line 1232-ish in ConfigureColumn() : 

    if (mask & GEOMETRY_CHANGED) {
        if (!Tk_IsMapped(tv->core.tkwin)) {
            TtkResizeWidget(&tv->core);
        } else {
          RecomputeSlack(tv);
          ResizeColumns(tv, TreeWidth(tv));
        }
    }

This fixes my application.

It appears that the tests (on linux) pass (though you should re-test).
I think resizecolumns() was getting called too many times when the window
was not mapped.

bll added on 2019-09-13 19:40:54:
Trying to re-create it, but it is difficult.

fvogel added on 2019-09-13 19:38:56:
Agreed. Can you provide a small script showing the issue perhaps?

bll added on 2019-09-13 19:34:57:
I agree that -stretch should have GEOMETRY_CHANGED.
That makes sense.

But somehow the call to Stretch() needs to be prevented before the
treeview has ever been drawn.

fvogel added on 2019-09-13 19:27:47:

That happed in the fix for the ticket I have pointed to. See [ce470f20fd] with associated fix [0e9cbdba9b2bf4c9].

Isn't it correct that changing the -stretch option should set GEOMETRY_CHANGED?


bll added on 2019-09-13 19:15:44:
What I think is happening:

The -stretch option was changed to act upon GEOMETRY_CHANGED.

I believe the Stretch() routine is getting called before the geometry is fully configured:

n: -399 width: 400 newwidth: 1 minwidth: 20
A: minwidth: 20 width: 400 n: -380
A:new width: 20

This looks to me like Stretch() is being called when [winfo (req)?width $win] is 
still set to 1, i.e. before the geometry is fully configured.

bll added on 2019-09-13 19:10:55:
The 8.6.8 screenshot shows how it should look (width=400).
The 8.6.10 screenshot shows what happens with 8.6.10, (width gets set to minwidth).
I think I know what is wrong, have to verify.

fvogel added on 2019-09-13 18:52:21:

From the posted snapshots, what's wrong is not obvious to me. But there were changes in the treeview code, yes. Example: [ce470f20fd]


bll added on 2019-09-13 17:54:52:
Something is resetting the width of the treeview.
The first line (A:) is before the treeview is packed.
This does not happen in version 8.6.8.

bll-tecra:bll$ ../ballroomdj.tcl
A: wid: 400
B: width 20

Attachments: