[PATCH STABLE] repowidget: stop the description column from shrinking on restart (refs #3882)

14 views
Skip to first unread message

Matt Harbison

unread,
Mar 29, 2015, 11:08:32 PM3/29/15
to thg...@googlegroups.com, matt_h...@yahoo.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1427491092 14400
# Fri Mar 27 17:18:12 2015 -0400
# Branch stable
# Node ID 1f7207198b558aa46910d2adcf6703d50a92a39a
# Parent 8d7476aab155938e1c54953b321b5b3fca026add
repowidget: stop the description column from shrinking on restart (refs #3882)

Previously, the description column would shrink by the width of the vertical
scrollbar, and the space was added to the last column. The width of the last
column was saved on exit, reloaded with that new size on the next start, and
then given another scrollbar width. After several restarts, a noticeable amount
of space was added to the last column, at the expense of the description.

This defers the column resizing until after the model is loaded, and the view is
cut down to make room for the vertical scrollbar, if necessary. It looks like
this was the same deferal used prior to 4358a32970a8, which landed in 3.3. On
some systems, there is a small lag where the columns are small before they snap
to their stored size.

diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -174,7 +174,7 @@
def _initView(self):
self._updateRepoViewForModel()
# restore column widths when model is initially loaded
- self.repoview.resizeColumns()
+ QTimer.singleShot(0, self.repoview.resizeColumns)

# select the widget chosen by the user
name = self.repo.ui.config('tortoisehg', 'defaultwidget')
thg.patch

Yuya Nishihara

unread,
Mar 30, 2015, 12:18:31 AM3/30/15
to thg...@googlegroups.com, Matt Harbison, matt_h...@yahoo.com
(To all, I don't want attached patches because I have to strip them manually
to import from maildir.)

On Sun, 29 Mar 2015 23:08:15 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1427491092 14400
> # Fri Mar 27 17:18:12 2015 -0400
> # Branch stable
> # Node ID 1f7207198b558aa46910d2adcf6703d50a92a39a
> # Parent 8d7476aab155938e1c54953b321b5b3fca026add
> repowidget: stop the description column from shrinking on restart (refs #3882)
>
> Previously, the description column would shrink by the width of the vertical
> scrollbar, and the space was added to the last column. The width of the last
> column was saved on exit, reloaded with that new size on the next start, and
> then given another scrollbar width. After several restarts, a noticeable amount
> of space was added to the last column, at the expense of the description.

> This defers the column resizing until after the model is loaded, and the view is
> cut down to make room for the vertical scrollbar, if necessary. It looks like
> this was the same deferal used prior to 4358a32970a8, which landed in 3.3. On
> some systems, there is a small lag where the columns are small before they snap
> to their stored size.

IIRC, your guess is wrong because these QTimers were started and queued at the
same time in RepoWidget.__init__(). But, it seems this patch can work around
the problem found by Deanna.

> diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
> --- a/tortoisehg/hgqt/repowidget.py
> +++ b/tortoisehg/hgqt/repowidget.py
> @@ -174,7 +174,7 @@
> def _initView(self):
> self._updateRepoViewForModel()
> # restore column widths when model is initially loaded
> - self.repoview.resizeColumns()
> + QTimer.singleShot(0, self.repoview.resizeColumns)

Can you add a detailed comment here?

It seems wrong to wait for the view is polished by deferred execution, but
will be good for stable.

Regards,

Matt Harbison

unread,
Mar 30, 2015, 12:42:35 AM3/30/15
to thg...@googlegroups.com, Yuya Nishihara, matt_h...@yahoo.com
It looks like pre-4358a32970a8 called _initModel() (which queued
_updateRepoViewForModel()), then queued resizeColumns(). With this patch,
_initView() is queued after _initModel(). _initView() calls
_updateRepoViewForModel() directly, and now queues resizeColumns().

I'm not sure how Qt works, but if this was Swing, the scheduled timers go
at the end of the queue- so now resizeColumns() gets called after any
events that may be queued up by _updateRepoViewForModel(), correct? I
have no idea what _updateRepoViewForModel() would be deferring though.

>> diff --git a/tortoisehg/hgqt/repowidget.py
>> b/tortoisehg/hgqt/repowidget.py
>> --- a/tortoisehg/hgqt/repowidget.py
>> +++ b/tortoisehg/hgqt/repowidget.py
>> @@ -174,7 +174,7 @@
>> def _initView(self):
>> self._updateRepoViewForModel()
>> # restore column widths when model is initially loaded
>> - self.repoview.resizeColumns()
>> + QTimer.singleShot(0, self.repoview.resizeColumns)
>
> Can you add a detailed comment here?

Will send a V2.

> It seems wrong to wait for the view is polished by deferred execution,
> but
> will be good for stable.

Agreed. I have no idea why the view wouldn't immediately know it needs to
draw a scrollbar as soon as the model is loaded.

> Regards,

Matt Harbison

unread,
Mar 30, 2015, 12:49:27 AM3/30/15
to thg...@googlegroups.com, matt_h...@yahoo.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1427491092 14400
# Fri Mar 27 17:18:12 2015 -0400
# Branch stable
# Node ID 51df4cb64567871fdfdaebfe45ed20371e9da774
# Parent 8d7476aab155938e1c54953b321b5b3fca026add
repowidget: stop the description column from shrinking on restart (refs #3882)

Previously, the description column would shrink by the width of the vertical
scrollbar, and the space was added to the last column. The width of the last
column was saved on exit, reloaded with that new size on the next start, and
then given another scrollbar width. After several restarts, a noticeable amount
of space was added to the last column, at the expense of the description.

This defers the column resizing until after the model is loaded, and the view is
cut down to make room for the vertical scrollbar, if necessary. It looks like
this was the same deferal used prior to 4358a32970a8, which landed in 3.3. On
some systems, there is a small lag where the columns are small before they snap
to their stored size.

diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -173,8 +173,12 @@
@pyqtSlot()
def _initView(self):
self._updateRepoViewForModel()
- # restore column widths when model is initially loaded
- self.repoview.resizeColumns()
+ # restore column widths when model is initially loaded. For some
+ # reason, this needs to be deferred after updating the view. Otherwise
+ # repoview.HgRepoView.resizeEvent() fires as the vertical scrollbar is
+ # added, which causes the last column to grow by the scrollbar width on
+ # each restart (and steal from the description width).

Yuya Nishihara

unread,
Mar 30, 2015, 1:31:07 AM3/30/15
to thg...@googlegroups.com, Matt Harbison, matt_h...@yahoo.com
pre-4358a32970a8:

__init__()
_initModel()
QTimer.singleShot(0, self._updateRepoViewForModel)
QTimer.singleShot(0, self.repoview.resizeColumns)

next eventloop
_updateRepoViewForModel()
repoview.resizeColumns()

4358a32970a8:

__init__()
QTimer.singleShot(0, self._initView)

next eventloop
_initView()
_updateRepoViewForModel()
repoview.resizeColumns()

your patch:

__init__()
QTimer.singleShot(0, self._initView)

next eventloop
_initView()
_updateRepoViewForModel()
QTimer.singleShot(0, self.repoview.resizeColumns)

# scheduled repaint might be here?

next eventloop
repoview.resizeColumns()

> Agreed. I have no idea why the view wouldn't immediately know it needs to
> draw a scrollbar as soon as the model is loaded.

Because Qt doesn't guarantee that the view is repainted immediately.

Regards,

Yuya Nishihara

unread,
Mar 30, 2015, 2:49:10 AM3/30/15
to thg...@googlegroups.com, Matt Harbison, matt_h...@yahoo.com
On Mon, 30 Mar 2015 00:49:11 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1427491092 14400
> # Fri Mar 27 17:18:12 2015 -0400
> # Branch stable
> # Node ID 51df4cb64567871fdfdaebfe45ed20371e9da774
> # Parent 8d7476aab155938e1c54953b321b5b3fca026add
> repowidget: stop the description column from shrinking on restart (refs #3882)
>
> Previously, the description column would shrink by the width of the vertical
> scrollbar, and the space was added to the last column. The width of the last
> column was saved on exit, reloaded with that new size on the next start, and
> then given another scrollbar width. After several restarts, a noticeable amount
> of space was added to the last column, at the expense of the description.
>
> This defers the column resizing until after the model is loaded, and the view is
> cut down to make room for the vertical scrollbar, if necessary. It looks like
> this was the same deferal used prior to 4358a32970a8, which landed in 3.3. On
> some systems, there is a small lag where the columns are small before they snap
> to their stored size.

Queued for stable, thanks.

I removed "It looks like this was the same deferal used prior to 4358a32970a8"
because 4358a32970a8^ had the same issue, at least on my Linux laptop.
Reply all
Reply to author
Forward
0 new messages