[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/soprano
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-03-08 9:06:14
Message-ID: 1268039174.759044.1465.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1100657 by trueg:

Do not reconnect the client when deleting a model. There is no need for \
that since the iterators are closed server-side already. Also this will \
prevent a crash in case the model is deleted as part of a global static \
when creating a socket will assert.


 M  +1 -1      CMakeLists.txt  
 M  +11 -5     client/clientconnection.cpp  
 M  +5 -1      client/clientconnection.h  
 M  +9 -2      client/clientmodel.cpp  
 M  +2 -2      client/localsocketclient.cpp  
 M  +2 -2      client/tcpclient.cpp  


--- trunk/kdesupport/soprano/CMakeLists.txt #1100656:1100657
@@ -7,7 +7,7 @@
 ##################  Soprano version  ################################
 set(CMAKE_SOPRANO_VERSION_MAJOR 2)
 set(CMAKE_SOPRANO_VERSION_MINOR 4)
-set(CMAKE_SOPRANO_VERSION_RELEASE 61)
+set(CMAKE_SOPRANO_VERSION_RELEASE 62)
 set(CMAKE_SOPRANO_VERSION_STRING \
"${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}")
  
 
--- trunk/kdesupport/soprano/client/clientconnection.cpp #1100656:1100657
@@ -74,6 +74,7 @@
     d->socketMutex.lock();
     // the sockets need to be deleted in their respective threads.
     // this is what d->socketStorage does. We only close them here.
+    // FIXME: QThreadStorage does NOT delete the local data in its \
destructor!  foreach( QIODevice* socket, d->sockets ) {
         socket->close();
     }
@@ -84,8 +85,7 @@
 
 QIODevice* Soprano::Client::ClientConnection::socket()
 {
-    if ( d->socketStorage.hasLocalData() &&
-         isConnected( d->socketStorage.localData()->socket() ) ) {
+    if ( isConnectedInCurrentThread() ) {
         return d->socketStorage.localData()->socket();
     }
     else if ( QIODevice* socket = newConnection() ) {
@@ -680,11 +680,17 @@
 }
 
 
-bool Soprano::Client::ClientConnection::testConnection()
+bool Soprano::Client::ClientConnection::connectInCurrentThread()
 {
-    QIODevice* s = socket();
-    return s ? isConnected( s ) : false;
+    return( socket() != 0 );
 }
 
+
+bool Soprano::Client::ClientConnection::isConnectedInCurrentThread()
+{
+    return ( d->socketStorage.hasLocalData() &&
+             isConnected( d->socketStorage.localData()->socket() ) );
+}
+
 #include "clientconnection.moc"
 #include "clientconnection_p.moc"
--- trunk/kdesupport/soprano/client/clientconnection.h #1100656:1100657
@@ -84,7 +84,11 @@
 
             bool checkProtocolVersion();
 
-            bool testConnection();
+            /// trueg: this is an awful design which simply grew over \
time. +            /// At some point this needs fixing a lot. Maybe by \
simply not +            /// Using Qt for communication.
+            bool connectInCurrentThread();
+            bool isConnectedInCurrentThread();
 
         protected:
             /**
--- trunk/kdesupport/soprano/client/clientmodel.cpp #1100656:1100657
@@ -42,8 +42,15 @@
 
 Soprano::Client::ClientModel::~ClientModel()
 {
-    for ( int i = 0; i < m_openIterators.count(); ++i ) {
-        m_client->iteratorClose( m_openIterators[i] );
+    //
+    // No need to close iterators if we are no longer
+    // connected. In that case the iterators have been
+    // closed by the server anyway.
+    //
+    if ( m_client->isConnectedInCurrentThread() ) {
+        for ( int i = 0; i < m_openIterators.count(); ++i ) {
+            m_client->iteratorClose( m_openIterators[i] );
+        }
     }
 }
 
--- trunk/kdesupport/soprano/client/localsocketclient.cpp #1100656:1100657
@@ -128,7 +128,7 @@
     if ( !isConnected() ) {
         disconnect(); // for cleanup
         d->connection = new LocalSocketClientConnection( name, this );
-        if ( d->connection->testConnection() &&
+        if ( d->connection->connectInCurrentThread() &&
              d->connection->checkProtocolVersion() ) {
             return true;
         }
@@ -146,7 +146,7 @@
 
 bool Soprano::Client::LocalSocketClient::isConnected() const
 {
-    return d->connection ? d->connection->testConnection() : false;
+    return d->connection ? d->connection->isConnectedInCurrentThread() : \
false;  }
 
 
--- trunk/kdesupport/soprano/client/tcpclient.cpp #1100656:1100657
@@ -117,7 +117,7 @@
     if ( !isConnected() ) {
         disconnect(); // for cleanup
         d->connection = new TcpClientConnection( address, port, this );
-        if ( d->connection->testConnection() &&
+        if ( d->connection->connectInCurrentThread() &&
              d->connection->checkProtocolVersion() ) {
             return true;
         }
@@ -135,7 +135,7 @@
 
 bool Soprano::Client::TcpClient::isConnected()
 {
-    return d->connection ? d->connection->testConnection() : false;
+    return d->connection ? d->connection->isConnectedInCurrentThread() : \
false;  }
 
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic