[PATCH 2/2] kernel-shark: Fix warnings from deprecated Qt APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux