diff mbox series

[10/12] kernel-shark: Avoid 0/0 spliter ratio in KsSession

Message ID 20190314151012.905-11-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various modifications and fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov March 14, 2019, 3:10 p.m. UTC
Sometimes when we save the session QSplitter::sizes() returns
0/0 ratio (no idea why). Later when we load the session the
0/0 ratio results in misbehavior of the splitter position.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsSession.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsSession.cpp b/kernel-shark/src/KsSession.cpp
index b151818..9d86776 100644
--- a/kernel-shark/src/KsSession.cpp
+++ b/kernel-shark/src/KsSession.cpp
@@ -256,7 +256,7 @@  void KsSession::loadSplitterSize(QSplitter *splitter)
 {
 	kshark_config_doc *spl = kshark_config_alloc(KS_CONFIG_JSON);
 	json_object *jspl, *jgraphsize, *jviewsize;
-	int graphSize, viewSize;
+	int graphSize(1), viewSize(1);
 	QList<int> sizes;
 
 	if (!kshark_config_doc_get(_config, "Splitter", spl))
@@ -269,6 +269,10 @@  void KsSession::loadSplitterSize(QSplitter *splitter)
 
 		graphSize = json_object_get_int(jgraphsize);
 		viewSize = json_object_get_int(jviewsize);
+		if (graphSize == 0 && viewSize == 0) {
+			/* 0/0 spliter ratio is undefined. Make it 1/1. */
+			viewSize = graphSize = 1;
+		}
 	}
 
 	sizes << graphSize << viewSize;