Skip to contentSkip to conversation

kernel-shark: Do not include trace-cmd.h in KsAdvFilteringDialog.cpp

PATCH New Yordan Karadzhov (VMware) 1 participant 2 messages Jul 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kernel-shark: Do not include trace-cmd.h in KsAdvFilteringDialog.cpp

This header is not needed.

---
 src/KsAdvFilteringDialog.cpp | 3 ---
 1 file changed, 3 deletions(-)
src/KsAdvFilteringDialog.cpp +0 -3
index f01467d..20412a7 100644
@@ -9,9 +9,6 @@
  *  @brief   GUI Dialog for Advanced filtering settings.
  */
 
-// trace-cmd
-#include <trace-cmd.h>
-
 // KernelShark
 #include "libkshark.h"
 #include "libkshark-tepdata.h"
Signature · 1 line
2.30.2
#1 lore raw

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

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.

---
 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(-)
CMakeLists.txt +6 -0
index 67dfb81..c2c0983 100644
@@ -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)
build/deff.h.cmake +1 -0
index 06cbf16..82379df 100644
@@ -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@"
src/KsGLWidget.cpp +10 -2
index 8aab7b3..3b2e0d4 100644
@@ -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);
src/KsUtils.cpp +3 -3
index 3db8951..364c25d 100644
@@ -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;
src/KsUtils.hpp +10 -0
index cf209bc..1a97d9e 100644
@@ -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 {
src/kernelshark.cpp +1 -1
index 8ed4948..92bc1f1 100644
@@ -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':
Signature · 1 line
2.30.2