Diffstat (limited to 'x11/ipc/server/ocopserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | x11/ipc/server/ocopserver.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp index 421e49c..4940cb8 100644 --- a/x11/ipc/server/ocopserver.cpp +++ b/x11/ipc/server/ocopserver.cpp | |||
@@ -211,42 +211,55 @@ void OCopServer::registerClient( int fd ) { | |||
211 | m_clients.insert( client.fd, client ); | 211 | m_clients.insert( client.fd, client ); |
212 | qWarning("clients are up to %d", m_clients.count() ); | 212 | qWarning("clients are up to %d", m_clients.count() ); |
213 | }; | 213 | }; |
214 | void OCopServer::deregisterClient(int fd ) { | 214 | void OCopServer::deregisterClient(int fd ) { |
215 | QMap<int, OCOPClient>::Iterator it = m_clients.find( fd ); | 215 | QMap<int, OCOPClient>::Iterator it = m_clients.find( fd ); |
216 | if (it != m_clients.end() ) { | 216 | if (it != m_clients.end() ) { |
217 | OCOPClient client = (*it); | 217 | OCOPClient client = it.data(); |
218 | delete client.notify; | 218 | delete client.notify; |
219 | m_clients.remove(fd ); | 219 | m_clients.remove(fd ); |
220 | close(fd ); | 220 | close(fd ); |
221 | /* | 221 | /* |
222 | * TIME_ME | 222 | * TIME_ME |
223 | * | 223 | * |
224 | * now delete from all channels | 224 | * now delete from all channels |
225 | * go through all channels | 225 | * go through all channels |
226 | * remove the fd from the list | 226 | * remove the fd from the list |
227 | * if count becomes 0 remove the channel | 227 | * if count becomes 0 remove the channel |
228 | * otherwise replace QArray<int> | 228 | * otherwise replace QArray<int> |
229 | */ | 229 | */ |
230 | QMap<QCString, QValueList<int> >::Iterator it; | 230 | QMap<QCString, QValueList<int> >::Iterator it2; |
231 | for ( it = m_channels.begin(); it != m_channels.end(); ++it ) { | 231 | repeatIt: |
232 | for ( it2 = m_channels.begin(); it2 != m_channels.end(); ++it2 ) { | ||
232 | /* | 233 | /* |
233 | * The channel contains this fd | 234 | * The channel contains this fd |
234 | */ | 235 | */ |
235 | if ( it.data().contains( fd ) ) { | 236 | qWarning("Channel %s", it2.key().data() ); |
236 | QValueList<int> array = it.data(); | 237 | if ( it2.data().contains( fd ) ) { |
238 | qWarning("contains"); | ||
239 | QValueList<int> array = it2.data(); | ||
237 | 240 | ||
238 | /* | 241 | /* |
239 | * remove channel or just replace | 242 | * remove channel or just replace |
240 | */ | 243 | */ |
241 | if ( array.count() == 1 ) { | 244 | if ( array.count() == 1 ) { |
245 | qWarning("Invalidate!"); | ||
242 | /* is the list now invalidatet? */ | 246 | /* is the list now invalidatet? */ |
243 | m_channels.remove( it ); | 247 | m_channels.remove( it2 ); |
248 | /* That is the first go to of my life | ||
249 | * but Iterator remove( Iterator ) | ||
250 | * does not exist | ||
251 | * it2 = --it2; | ||
252 | * does not work reliable too | ||
253 | * so the only way is to reiterate :( | ||
254 | */ | ||
255 | goto repeatIt; | ||
244 | }else{ | 256 | }else{ |
257 | qWarning("removing"); | ||
245 | array.remove( fd ); | 258 | array.remove( fd ); |
246 | it = m_channels.replace( it.key(), array ); | 259 | it2 = m_channels.replace( it2.key(), array ); |
247 | } | 260 | } |
248 | } | 261 | } |
249 | } // off all channels | 262 | } // off all channels |
250 | } | 263 | } |
251 | qWarning("clients are now at %d", m_clients.count() ); | 264 | qWarning("clients are now at %d", m_clients.count() ); |
252 | }; | 265 | }; |