[PATCH] csinfo: fix crash when stripping commits

10 views
Skip to first unread message

Antonio Muci

unread,
Sep 20, 2024, 4:54:11 PM9/20/24
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1726863202 -7200
# Fri Sep 20 22:13:22 2024 +0200
# Branch stable
# Node ID 7804ef571513e1957100898a0f9f32cfa470328c
# Parent 1f17abd911a232e537b7b1c1982f7a43b4d2f025
csinfo: fix crash when stripping commits

This commit fixes a bug introduced in a015c03d91c6 ("cslist: fix
[signature-mismatch] issues overriding QWidget.update()"), which modified
cslit.ChangesetList. Invoking "Modify History | Strip" would result in a crash.

Discussion at https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5991

diff --git a/tortoisehg/hgqt/csinfo.py b/tortoisehg/hgqt/csinfo.py
--- a/tortoisehg/hgqt/csinfo.py
+++ b/tortoisehg/hgqt/csinfo.py
@@ -9,6 +9,7 @@ from __future__ import annotations

import binascii
import re
+import sys

from .qtcore import (
QSize,
@@ -435,7 +436,21 @@ class SummaryPanel(SummaryBase, QWidget)
self.revlabel = None
self.expand_btn = qtlib.PMButton()

- def update(self, target=None, style=None, custom=None, repo=None):
+ # TODO: drop this when all callers are removed, since it hides update() in
+ # the superclass, which seems related to painting the component, or an area
+ # of it.
+ def update(self, target=None, style=None, custom=None, repo=None): # pytype: disable=signature-mismatch
+ import warnings
+
+ warnings.warn(
+ "SummaryPanel.update() should be changed to SummaryPanel.updateItems()",
+ DeprecationWarning,
+ 2,
+ )
+ sys.stderr.flush()
+ self.updateItems(target, style, custom, repo)
+
+ def updateItems(self, target=None, style=None, custom=None, repo=None):
SummaryBase.update(self, target, custom, repo)

layout = self.layout()

Yuya Nishihara

unread,
Sep 20, 2024, 6:13:47 PM9/20/24
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Fri, 20 Sep 2024 22:54:08 +0200, 'Antonio Muci' via TortoiseHg Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1726863202 -7200
> # Fri Sep 20 22:13:22 2024 +0200
> # Branch stable
> # Node ID 7804ef571513e1957100898a0f9f32cfa470328c
> # Parent 1f17abd911a232e537b7b1c1982f7a43b4d2f025
> csinfo: fix crash when stripping commits
>
> This commit fixes a bug introduced in a015c03d91c6 ("cslist: fix
> [signature-mismatch] issues overriding QWidget.update()"), which modified
> cslit.ChangesetList. Invoking "Modify History | Strip" would result in a crash.

Good catch.

Maybe we should rename other `update()` in SummaryBase subclasses? and
widget.update() in Factory.__call__()?

Matt Harbison

unread,
Sep 20, 2024, 11:02:35 PM9/20/24
to TortoiseHg Developers
Probably.  SummaryBase.update() lacks the `style` arg that SummaryPanel.update() has, so it's not an override as it is.  (Is this a bug?)  But I guess with the multiple inheritance on SummaryPanel, a call to update would resolve to the SummaryBase method instead of QWidget?

I remember the factory stuff here had me completely lost when porting str -> bytes for py3 support.

Yuya Nishihara

unread,
Sep 20, 2024, 11:24:25 PM9/20/24
to 'Matt Harbison' via TortoiseHg Developers
On Fri, 20 Sep 2024 20:02:35 -0700 (PDT), 'Matt Harbison' via TortoiseHg Developers wrote:
> On Friday, September 20, 2024 at 6:13:47 PM UTC-4 Yuya Nishihara wrote:
> Maybe we should rename other `update()` in SummaryBase subclasses? and
> widget.update() in Factory.__call__()?
>
>
> Probably. SummaryBase.update() lacks the `style` arg that
> SummaryPanel.update() has, so it's not an override as it is. (Is this a
> bug?)

These parameters have default values, so it kinda works.

> But I guess with the multiple inheritance on SummaryPanel, a call to
> update would resolve to the SummaryBase method instead of QWidget?

No, it's not C++. SummaryPanel.update() shadows inherited methods, and
SummaryPanel.update() calls SummaryBase.update(), not QWidget.update().

It's a total mess.
Reply all
Reply to author
Forward
0 new messages