From d18fd83f5b6122b74fb14bc9ca17be26a231ca8a Mon Sep 17 00:00:00 2001 From: peri4 Date: Thu, 10 Jun 2021 20:06:01 +0300 Subject: [PATCH] piintrospector fixes --- utils/piintrospector/piintrospector.cpp | 31 ++++++++++++++++--------- utils/piintrospector/piintrospector.h | 4 +--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/utils/piintrospector/piintrospector.cpp b/utils/piintrospector/piintrospector.cpp index 1ee6ee0..c6cf3da 100644 --- a/utils/piintrospector/piintrospector.cpp +++ b/utils/piintrospector/piintrospector.cpp @@ -20,9 +20,9 @@ QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("_ CONNECTU_QUEUED(&peer, peerConnectedEvent, this, peersChanged, this); CONNECTU_QUEUED(&peer, peerDisconnectedEvent, this, peersChanged, this); CONNECTU_QUEUED(&peer, dataReceivedEvent, this, peerReceived, this); - CONNECTU(&peer, peerConnectedEvent, this, reqProcPIEvents); - CONNECTU(&peer, peerDisconnectedEvent, this, reqProcPIEvents); - CONNECTU(&peer, dataReceivedEvent, this, reqProcPIEvents); + //CONNECTU(&peer, peerConnectedEvent, this, reqProcPIEvents); + //CONNECTU(&peer, peerDisconnectedEvent, this, reqProcPIEvents); + //CONNECTU(&peer, dataReceivedEvent, this, reqProcPIEvents); session.addEntry(this); session.addEntry(tabWidgetMain); PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIIntrospection::InfoTypes"); @@ -35,7 +35,7 @@ QPIIntrospector::QPIIntrospector(QWidget * parent): EMainWindow(parent), peer("_ session.addEntry(cb); } } - //startTimer(100); + pip_timer = startTimer(10); session.load(); peer.start(); } @@ -59,6 +59,8 @@ void QPIIntrospector::changeEvent(QEvent * e) { void QPIIntrospector::timerEvent(QTimerEvent * e) { + if (e->timerId() == pip_timer) + callQueuedEvents(); if (e->timerId() == request_timer) buttonRequest->click(); } @@ -158,7 +160,7 @@ QString QPIIntrospector::durationStr(PISystemTime t) { void QPIIntrospector::on_listApp_currentRowChanged(int r) { PIString cs; if (r < 0) cs.clear(); - else cs = Q2PIString(listApp->item(r)->text()); + else cs = Q2PIString(listApp->item(r)->data(Qt::UserRole).toString()); if (cur_server != cs) widgetContainers->clear(); cur_server = cs; @@ -172,34 +174,37 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da if (ba.size_s() < 4) return; uint sign(0); ba >> sign; if (sign != PIIntrospection::sign) return; + int cnt = 0; + ba >> cnt; + piCout << cnt << ba.size(); PIChunkStream cs(ba); PIByteArray pba; while (!cs.atEnd()) { switch (cs.read()) { case PIIntrospection::itInfo: { - cs.get(pba); + pba.clear(); cs.get(pba); PIIntrospection::unpackInfo(pba, info); } break; case PIIntrospection::itProcStat: { - cs.get(pba); + pba.clear(); cs.get(pba); PIIntrospection::unpackProcStat(pba, stat); widgetThreads->setStat(stat.threads); //showInfo(info); } break; case PIIntrospection::itContainers: { - cs.get(pba); + pba.clear(); cs.get(pba); PIVector data; PIIntrospection::unpackContainers(pba, data); widgetContainers->showContainers(data); } break; case PIIntrospection::itObjects: { - cs.get(pba); + pba.clear(); cs.get(pba); PIVector objects; PIIntrospection::unpackObjects(pba, objects); widgetObjects->showObjects(objects); } break; case PIIntrospection::itThreads: { - cs.get(pba); + pba.clear(); cs.get(pba); PIVector threads; PIIntrospection::unpackThreads(pba, threads); widgetThreads->showThreads(threads); @@ -212,13 +217,17 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da void QPIIntrospector::peersChanged(const PIString & name) { + static QString tag = "__introspection__server_"; listApp->blockSignals(true); QString cs = listApp->currentItem() ? listApp->currentItem()->text() : ""; listApp->clear(); peer.lock(); piForeachC (PIPeer::PeerInfo & p, peer.allPeers()) { QString pn = PI2QString(p.name); - listApp->addItem(pn); + if (!pn.contains(tag)) continue; + QListWidgetItem * li = new QListWidgetItem(pn.left(pn.indexOf(tag))); + li->setData(Qt::UserRole, pn); + listApp->addItem(li); if (pn == cs) listApp->setCurrentRow(listApp->count() - 1); } diff --git a/utils/piintrospector/piintrospector.h b/utils/piintrospector/piintrospector.h index 7a89da0..b85f7ba 100644 --- a/utils/piintrospector/piintrospector.h +++ b/utils/piintrospector/piintrospector.h @@ -26,7 +26,6 @@ protected: void buildDumpSection(QTreeWidgetItem * pi, PIString & str); void showInfo(); - EVENT_HANDLER(void, reqProcPIEvents) {QMetaObject::invokeMethod(this, "procPIEvents", Qt::QueuedConnection);} QString durationStr(PISystemTime t); EVENT_HANDLER2(void, peerReceived, const PIString &, from, const PIByteArray &, data); @@ -36,10 +35,9 @@ protected: PIIntrospection::ProcessInfo info; PIIntrospection::ProcessStat stat; PIPeer peer; - int request_timer; + int request_timer, pip_timer; private slots: - void procPIEvents() {callQueuedEvents();} void buildTree(QByteArray d); void procRequestTimer(); void on_listApp_currentRowChanged(int r);