summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11/qt/qcopchannel_qws.cpp
Side-by-side diff
Diffstat (limited to 'x11/libqpe-x11/qt/qcopchannel_qws.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qt/qcopchannel_qws.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.cpp b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
index e90f056..1cea80c 100644
--- a/x11/libqpe-x11/qt/qcopchannel_qws.cpp
+++ b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
@@ -6,2 +6,3 @@
QList<QCopChannel>* QCopChannel::m_list = 0;
+QMap<QCString, int> QCopChannel::m_refCount;
@@ -10,6 +11,15 @@ QCopChannel::QCopChannel( const QCString& channel, QObject* parent,
: QObject( parent, name ),m_chan(channel) {
- init();
if (!m_list ) {
m_list = new QList<QCopChannel>;
+ /* only connect once */
+ connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
+ this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) );
}
+ /* first registration or ref count is 0 for m_chan*/
+ if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) {
+ m_refCount[m_chan] = 1;
+ OCOPClient::self()->addChannel( m_chan );
+ }else
+ m_refCount[m_chan]++;
+
m_list->append(this);
@@ -20,2 +30,9 @@ void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) {
QCopChannel::~QCopChannel() {
+ if (m_refCount[m_chan] == 1 ) {
+ OCOPClient::self()->delChannel( m_chan );
+ m_refCount[m_chan] = 0;
+ }else
+ m_refCount[m_chan]--;
+
+
m_list->remove(this);
@@ -25,8 +42,3 @@ QCopChannel::~QCopChannel() {
}
- OCOPClient::self()->delChannel( m_chan );
-}
-void QCopChannel::init() {
- OCOPClient::self()->addChannel( m_chan );
- connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
- this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) );
+
}
@@ -49,2 +61,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
const QByteArray& ar ) {
+ qWarning("Client:sendLocally %s %s", chann.data(), msg.data() );
if (!m_list )
@@ -52,2 +65,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
QCopChannel* chan;
+
for ( chan = m_list->first(); chan; chan = m_list->next() ) {
@@ -60,4 +74,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) {
- if (chan == m_chan )
- emit received(msg, ar );
+ sendLocally( chan, msg, ar );
}