From patchwork Fri Aug 14 19:12:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1345175 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BStPq0H6Hz9sPB for ; Sat, 15 Aug 2020 05:13:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AEEF588DC8; Fri, 14 Aug 2020 19:13:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nSS1UK-7qFuy; Fri, 14 Aug 2020 19:13:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 9C8E788D8B; Fri, 14 Aug 2020 19:13:11 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 04DE41BF45A for ; Fri, 14 Aug 2020 19:13:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BAD772151E for ; Fri, 14 Aug 2020 19:13:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GxBri2iN5rJk for ; Fri, 14 Aug 2020 19:13:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by silver.osuosl.org (Postfix) with ESMTPS id 5C59B203C8 for ; Fri, 14 Aug 2020 19:13:06 +0000 (UTC) Received: from localhost (lfbn-bay-1-248-77.w83-193.abo.wanadoo.fr [83.193.91.77]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 6DA07100006; Fri, 14 Aug 2020 19:13:02 +0000 (UTC) From: Thomas Petazzoni To: buildroot@buildroot.org Date: Fri, 14 Aug 2020 21:12:58 +0200 Message-Id: <20200814191258.984535-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] package/pulseview: fix build with recent Qt versions X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit backports an upstream commit to fix the build of pulseview with recent Qt versions. Note that pulseview has a 0.4.2 version (newer than our 0.4.1) but it doesn't have the fix we need. And 0.4.2 now requires additional Qt translation tools, so the update to 0.4.2 is anyway not straightforward. Fixes: http://autobuild.buildroot.net/results/c9e27a91905dfda0ba1ddb12c7910316d3ee82ef/ Signed-off-by: Thomas Petazzoni --- ...place-obsolete-deprecated-Qt-methods.patch | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 package/pulseview/0002-Replace-obsolete-deprecated-Qt-methods.patch diff --git a/package/pulseview/0002-Replace-obsolete-deprecated-Qt-methods.patch b/package/pulseview/0002-Replace-obsolete-deprecated-Qt-methods.patch new file mode 100644 index 0000000000..42cdc467be --- /dev/null +++ b/package/pulseview/0002-Replace-obsolete-deprecated-Qt-methods.patch @@ -0,0 +1,133 @@ +From caacc9bc622238ca48674ea6f40d07466e4b97a5 Mon Sep 17 00:00:00 2001 +From: Valentin Ochs +Date: Sat, 20 Jun 2020 16:01:27 +0200 +Subject: [PATCH] Replace obsolete/deprecated Qt methods + +[Thomas: Backport from upstream commit +ae726b70a7ada9a4be5808e00f0c951318479684, one conflict manually +resolved in pv/util.cpp.] +Signed-off-by: Thomas Petazzoni +--- + pv/util.cpp | 21 +++++++++++++++++++-- + pv/util.hpp | 10 ++++++++++ + pv/views/trace/decodetrace.cpp | 3 ++- + pv/views/trace/ruler.cpp | 2 +- + pv/widgets/timestampspinbox.cpp | 2 +- + 5 files changed, 33 insertions(+), 5 deletions(-) + +diff --git a/pv/util.cpp b/pv/util.cpp +index 49b9467c..2a63038d 100644 +--- a/pv/util.cpp ++++ b/pv/util.cpp +@@ -137,7 +137,7 @@ QString format_time_si(const Timestamp& v, SIPrefix prefix, + QString s; + QTextStream ts(&s); + if (sign && !v.is_zero()) +- ts << forcesign; ++ ts.setNumberFlags(ts.numberFlags() | QTextStream::ForceSign); + ts << qSetRealNumberPrecision(precision) << (v * multiplier) << ' ' + << prefix << unit; + +@@ -171,7 +171,7 @@ QString format_value_si(double v, SIPrefix prefix, unsigned precision, + QString s; + QTextStream ts(&s); + if (sign && (v != 0)) +- ts << forcesign; ++ ts.setNumberFlags(ts.numberFlags() | QTextStream::ForceSign); + ts.setRealNumberNotation(QTextStream::FixedNotation); + ts.setRealNumberPrecision(precision); + ts << (v * multiplier) << ' ' << prefix << unit; +@@ -281,5 +281,22 @@ vector split_string(string text, string separator) + return result; + } + ++/** ++ * Return the width of a string in a given font. ++ * ++ * @param[in] metric metrics of the font ++ * @param[in] string the string whose width should be determined ++ * ++ * @return width of the string in pixels ++ */ ++std::streamsize text_width(const QFontMetrics &metric, const QString &string) ++{ ++#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) ++ return metric.horizontalAdvance(string); ++#else ++ return metric.width(string); ++#endif ++} ++ + } // namespace util + } // namespace pv +diff --git a/pv/util.hpp b/pv/util.hpp +index dd7be222..ad904f85 100644 +--- a/pv/util.hpp ++++ b/pv/util.hpp +@@ -30,6 +30,7 @@ + + #include + #include ++#include + + using std::string; + using std::vector; +@@ -137,6 +138,15 @@ QString format_time_minutes(const Timestamp& t, signed precision = 0, + + vector split_string(string text, string separator); + ++/** ++ * Return the width of a string in a given font. ++ * @param[in] metric metrics of the font ++ * @param[in] string the string whose width should be determined ++ * ++ * @return width of the string in pixels ++ */ ++std::streamsize text_width(const QFontMetrics &metric, const QString &string); ++ + } // namespace util + } // namespace pv + +diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp +index 9c7196bf..1ee7ae9f 100644 +--- a/pv/views/trace/decodetrace.cpp ++++ b/pv/views/trace/decodetrace.cpp +@@ -103,7 +103,8 @@ DecodeTrace::DecodeTrace(pv::Session &session, + + // Determine shortest string we want to see displayed in full + QFontMetrics m(QApplication::font()); +- min_useful_label_width_ = m.width("XX"); // e.g. two hex characters ++ // e.g. two hex characters ++ min_useful_label_width_ = util::text_width(m, "XX"); + + // For the base color, we want to start at a very different color for + // every decoder stack, so multiply the index with a number that is +diff --git a/pv/views/trace/ruler.cpp b/pv/views/trace/ruler.cpp +index acea8a36..68134966 100644 +--- a/pv/views/trace/ruler.cpp ++++ b/pv/views/trace/ruler.cpp +@@ -218,7 +218,7 @@ void Ruler::paintEvent(QPaintEvent*) + const int rightedge = width(); + const int x_tick = tick.first; + if ((x_tick > leftedge) && (x_tick < rightedge)) { +- const int x_left_bound = QFontMetrics(font()).width(tick.second) / 2; ++ const int x_left_bound = util::text_width(QFontMetrics(font()), tick.second) / 2; + const int x_right_bound = rightedge - x_left_bound; + const int x_legend = min(max(x_tick, x_left_bound), x_right_bound); + p.drawText(x_legend, ValueMargin, 0, text_height, +diff --git a/pv/widgets/timestampspinbox.cpp b/pv/widgets/timestampspinbox.cpp +index 21b3d0d7..383aed1f 100644 +--- a/pv/widgets/timestampspinbox.cpp ++++ b/pv/widgets/timestampspinbox.cpp +@@ -75,7 +75,7 @@ QSize TimestampSpinBox::minimumSizeHint() const + { + const QFontMetrics fm(fontMetrics()); + const int l = round(value_).str().size() + precision_ + 10; +- const int w = fm.width(QString(l, '0')); ++ const int w = util::text_width(fm, QString(l, '0')); + const int h = lineEdit()->minimumSizeHint().height(); + return QSize(w, h); + } +-- +2.26.2 +