From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 2/2] kernel-shark: Fix warnings from deprecated Qt APIs
Date: Tue, 27 Jul 2021 16:42:25 +0300 [thread overview]
Message-ID: <20210727134225.25025-2-y.karadz@gmail.com> (raw)
In-Reply-To: <20210727134225.25025-1-y.karadz@gmail.com>
Couple of APIs used by KernelShark have been marked as deprecated
in the recent version of Qt. Fix all compilation warnings caused
by the usage of these deprecated APIs.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
CMakeLists.txt | 6 ++++++
build/deff.h.cmake | 1 +
src/KsGLWidget.cpp | 12 ++++++++++--
src/KsUtils.cpp | 6 +++---
src/KsUtils.hpp | 10 ++++++++++
src/kernelshark.cpp | 2 +-
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67dfb81..c2c0983 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,6 +83,12 @@ if (Qt5Widgets_FOUND)
endif()
+ if(Qt5Widgets_VERSION VERSION_LESS "5.15")
+
+ set(QT_VERSION_LESS_5_15 TRUE)
+
+ endif()
+
endif (Qt5Widgets_FOUND)
find_package (Boost COMPONENTS unit_test_framework)
diff --git a/build/deff.h.cmake b/build/deff.h.cmake
index 06cbf16..82379df 100644
--- a/build/deff.h.cmake
+++ b/build/deff.h.cmake
@@ -31,6 +31,7 @@
/** Qt - old version detected. */
#cmakedefine QT_VERSION_LESS_5_11
+#cmakedefine QT_VERSION_LESS_5_15
/** Location of the KernelShark tests. */
#cmakedefine KS_TEST_DIR "@KS_TEST_DIR@"
diff --git a/src/KsGLWidget.cpp b/src/KsGLWidget.cpp
index 8aab7b3..3b2e0d4 100644
--- a/src/KsGLWidget.cpp
+++ b/src/KsGLWidget.cpp
@@ -345,10 +345,18 @@ void KsGLWidget::wheelEvent(QWheelEvent * event)
* Use the position of the mouse as a focus point for the
* zoom.
*/
- zoomFocus = event->pos().x() - _bin0Offset();
+#ifdef QT_VERSION_LESS_5_15
+
+ zoomFocus = event->pos().x() - _bin0Offset();
+
+#else
+
+ zoomFocus = event->position().x() - _bin0Offset();
+
+#endif // QT_VERSION_LESS_5_15
}
- if (event->delta() > 0) {
+ if (event->angleDelta().y() > 0) {
_model.zoomIn(.05, zoomFocus);
} else {
_model.zoomOut(.05, zoomFocus);
diff --git a/src/KsUtils.cpp b/src/KsUtils.cpp
index 3db8951..364c25d 100644
--- a/src/KsUtils.cpp
+++ b/src/KsUtils.cpp
@@ -486,7 +486,7 @@ QString getSaveFile(QWidget *parent,
*/
QStringList splitArguments(QString cmd)
{
- QString::SplitBehavior opt = QString::SkipEmptyParts;
+ auto opt = KS_SPLIT_SkipEmptyParts;
int i, progress = 0, size;
QStringList argv;
QChar quote = 0;
@@ -527,7 +527,7 @@ QStringList splitArguments(QString cmd)
*/
QVector<int> parseIdList(QString v_str)
{
- QStringList list = v_str.split(",", QString::SkipEmptyParts);
+ QStringList list = v_str.split(",", KS_SPLIT_SkipEmptyParts);
QVector<int> v;
for (auto item: list) {
@@ -553,7 +553,7 @@ QVector<int> parseIdList(QString v_str)
*/
QMap<int, QVector<int>> parseTaskList(QString v_str)
{
- QStringList taskList = v_str.split(",", QString::SkipEmptyParts);
+ QStringList taskList = v_str.split(",", KS_SPLIT_SkipEmptyParts);
QVector<int> streamIds, allPids;
kshark_context *kshark_ctx(nullptr);
QMap<int, QVector<int>> ret;
diff --git a/src/KsUtils.hpp b/src/KsUtils.hpp
index cf209bc..1a97d9e 100644
--- a/src/KsUtils.hpp
+++ b/src/KsUtils.hpp
@@ -86,6 +86,16 @@ typedef std::chrono::high_resolution_clock::time_point hd_time;
std::chrono::duration_cast<std::chrono::duration<double>>( \
std::chrono::high_resolution_clock::now() - t0).count()
+#ifdef QT_VERSION_LESS_5_15
+
+ #define KS_SPLIT_SkipEmptyParts QString::SkipEmptyParts
+
+#else
+
+ #define KS_SPLIT_SkipEmptyParts Qt::SkipEmptyParts
+
+#endif // QT_VERSION_LESS_5_15
+
//! @endcond
namespace KsUtils {
diff --git a/src/kernelshark.cpp b/src/kernelshark.cpp
index 8ed4948..92bc1f1 100644
--- a/src/kernelshark.cpp
+++ b/src/kernelshark.cpp
@@ -87,7 +87,7 @@ int main(int argc, char **argv)
break;
case 'a':
- appInputFiles << QString(optarg).split(" ", QString::SkipEmptyParts);
+ appInputFiles << QString(optarg).split(" ", KS_SPLIT_SkipEmptyParts);
break;
case 'p':
--
2.30.2
prev parent reply other threads:[~2021-07-27 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 13:42 [PATCH 1/2] kernel-shark: Do not include trace-cmd.h in KsAdvFilteringDialog.cpp Yordan Karadzhov (VMware)
2021-07-27 13:42 ` Yordan Karadzhov (VMware) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210727134225.25025-2-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).