Changeset View
Changeset View
Standalone View
Standalone View
ksmserver/logout.cpp
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | 178 | { | |||
---|---|---|---|---|---|
205 | palette.setColor( QApplication::desktop()->backgroundRole(), Qt::black ); | 205 | palette.setColor( QApplication::desktop()->backgroundRole(), Qt::black ); | ||
206 | QApplication::setPalette(palette); | 206 | QApplication::setPalette(palette); | ||
207 | wmPhase1WaitingCount = 0; | 207 | wmPhase1WaitingCount = 0; | ||
208 | saveType = saveSession?SmSaveBoth:SmSaveGlobal; | 208 | saveType = saveSession?SmSaveBoth:SmSaveGlobal; | ||
209 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | 209 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | ||
210 | performLegacySessionSave(); | 210 | performLegacySessionSave(); | ||
211 | #endif | 211 | #endif | ||
212 | startProtection(); | 212 | startProtection(); | ||
213 | foreach( KSMClient* c, clients ) { | 213 | for ( KSMClient* c : qAsConst(clients) ) { | ||
214 | c->resetState(); | 214 | c->resetState(); | ||
215 | // Whoever came with the idea of phase 2 got it backwards | 215 | // Whoever came with the idea of phase 2 got it backwards | ||
216 | // unfortunately. Window manager should be the very first | 216 | // unfortunately. Window manager should be the very first | ||
217 | // one saving session data, not the last one, as possible | 217 | // one saving session data, not the last one, as possible | ||
218 | // user interaction during session save may alter | 218 | // user interaction during session save may alter | ||
219 | // window positions etc. | 219 | // window positions etc. | ||
220 | // Moreover, KWin's focus stealing prevention would lead | 220 | // Moreover, KWin's focus stealing prevention would lead | ||
221 | // to undesired effects while session saving (dialogs | 221 | // to undesired effects while session saving (dialogs | ||
222 | // wouldn't be activated), so it needs be assured that | 222 | // wouldn't be activated), so it needs be assured that | ||
223 | // KWin will turn it off temporarily before any other | 223 | // KWin will turn it off temporarily before any other | ||
224 | // user interaction takes place. | 224 | // user interaction takes place. | ||
225 | // Therefore, make sure the WM finishes its phase 1 | 225 | // Therefore, make sure the WM finishes its phase 1 | ||
226 | // before others a chance to change anything. | 226 | // before others a chance to change anything. | ||
227 | // KWin will check if the session manager is ksmserver, | 227 | // KWin will check if the session manager is ksmserver, | ||
228 | // and if yes it will save in phase 1 instead of phase 2. | 228 | // and if yes it will save in phase 1 instead of phase 2. | ||
229 | if( isWM( c ) ) | 229 | if( isWM( c ) ) | ||
230 | ++wmPhase1WaitingCount; | 230 | ++wmPhase1WaitingCount; | ||
231 | } | 231 | } | ||
232 | if (wmPhase1WaitingCount > 0) { | 232 | if (wmPhase1WaitingCount > 0) { | ||
233 | foreach( KSMClient* c, clients ) { | 233 | for ( KSMClient* c : qAsConst(clients) ) { | ||
234 | if( isWM( c ) ) | 234 | if( isWM( c ) ) | ||
235 | SmsSaveYourself( c->connection(), saveType, | 235 | SmsSaveYourself( c->connection(), saveType, | ||
236 | true, SmInteractStyleAny, false ); | 236 | true, SmInteractStyleAny, false ); | ||
237 | } | 237 | } | ||
238 | } else { // no WM, simply start them all | 238 | } else { // no WM, simply start them all | ||
239 | foreach( KSMClient* c, clients ) | 239 | for ( KSMClient* c : qAsConst(clients) ) | ||
240 | SmsSaveYourself( c->connection(), saveType, | 240 | SmsSaveYourself( c->connection(), saveType, | ||
241 | true, SmInteractStyleAny, false ); | 241 | true, SmInteractStyleAny, false ); | ||
242 | } | 242 | } | ||
243 | qCDebug(KSMSERVER) << "clients should be empty, " << clients.isEmpty(); | 243 | qCDebug(KSMSERVER) << "clients should be empty, " << clients.isEmpty(); | ||
244 | if ( clients.isEmpty() ) | 244 | if ( clients.isEmpty() ) | ||
245 | completeShutdownOrCheckpoint(); | 245 | completeShutdownOrCheckpoint(); | ||
246 | } | 246 | } | ||
247 | 247 | | |||
248 | void KSMServer::saveCurrentSession() | 248 | void KSMServer::saveCurrentSession() | ||
249 | { | 249 | { | ||
250 | if ( state != Idle ) | 250 | if ( state != Idle ) | ||
251 | return; | 251 | return; | ||
252 | 252 | | |||
253 | if ( currentSession().isEmpty() || currentSession() == QString::fromLocal8Bit( SESSION_PREVIOUS_LOGOUT ) ) | 253 | if ( currentSession().isEmpty() || currentSession() == QString::fromLocal8Bit( SESSION_PREVIOUS_LOGOUT ) ) | ||
254 | sessionGroup = QStringLiteral("Session: ") + QString::fromLocal8Bit( SESSION_BY_USER ); | 254 | sessionGroup = QStringLiteral("Session: ") + QString::fromLocal8Bit( SESSION_BY_USER ); | ||
255 | 255 | | |||
256 | state = Checkpoint; | 256 | state = Checkpoint; | ||
257 | wmPhase1WaitingCount = 0; | 257 | wmPhase1WaitingCount = 0; | ||
258 | saveType = SmSaveLocal; | 258 | saveType = SmSaveLocal; | ||
259 | saveSession = true; | 259 | saveSession = true; | ||
260 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | 260 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | ||
261 | performLegacySessionSave(); | 261 | performLegacySessionSave(); | ||
262 | #endif | 262 | #endif | ||
263 | foreach( KSMClient* c, clients ) { | 263 | for ( KSMClient* c : qAsConst(clients) ) { | ||
264 | c->resetState(); | 264 | c->resetState(); | ||
265 | if( isWM( c ) ) | 265 | if( isWM( c ) ) | ||
266 | ++wmPhase1WaitingCount; | 266 | ++wmPhase1WaitingCount; | ||
267 | } | 267 | } | ||
268 | if (wmPhase1WaitingCount > 0) { | 268 | if (wmPhase1WaitingCount > 0) { | ||
269 | foreach( KSMClient* c, clients ) { | 269 | for ( KSMClient* c : qAsConst(clients) ) { | ||
270 | if( isWM( c ) ) | 270 | if( isWM( c ) ) | ||
271 | SmsSaveYourself( c->connection(), saveType, false, SmInteractStyleNone, false ); | 271 | SmsSaveYourself( c->connection(), saveType, false, SmInteractStyleNone, false ); | ||
272 | } | 272 | } | ||
273 | } else { | 273 | } else { | ||
274 | foreach( KSMClient* c, clients ) | 274 | for ( KSMClient* c : qAsConst(clients) ) | ||
275 | SmsSaveYourself( c->connection(), saveType, false, SmInteractStyleNone, false ); | 275 | SmsSaveYourself( c->connection(), saveType, false, SmInteractStyleNone, false ); | ||
276 | } | 276 | } | ||
277 | if ( clients.isEmpty() ) | 277 | if ( clients.isEmpty() ) | ||
278 | completeShutdownOrCheckpoint(); | 278 | completeShutdownOrCheckpoint(); | ||
279 | } | 279 | } | ||
280 | 280 | | |||
281 | void KSMServer::saveCurrentSessionAs( const QString &session ) | 281 | void KSMServer::saveCurrentSessionAs( const QString &session ) | ||
282 | { | 282 | { | ||
Show All 26 Lines | 305 | } else { | |||
309 | client->saveYourselfDone = true; | 309 | client->saveYourselfDone = true; | ||
310 | completeShutdownOrCheckpoint(); | 310 | completeShutdownOrCheckpoint(); | ||
311 | } | 311 | } | ||
312 | startProtection(); | 312 | startProtection(); | ||
313 | if( isWM( client ) && !client->wasPhase2 && wmPhase1WaitingCount > 0 ) { | 313 | if( isWM( client ) && !client->wasPhase2 && wmPhase1WaitingCount > 0 ) { | ||
314 | --wmPhase1WaitingCount; | 314 | --wmPhase1WaitingCount; | ||
315 | // WM finished its phase1, save the rest | 315 | // WM finished its phase1, save the rest | ||
316 | if( wmPhase1WaitingCount == 0 ) { | 316 | if( wmPhase1WaitingCount == 0 ) { | ||
317 | foreach( KSMClient* c, clients ) | 317 | for ( KSMClient* c : qAsConst(clients) ) | ||
318 | if( !isWM( c )) | 318 | if( !isWM( c )) | ||
319 | SmsSaveYourself( c->connection(), saveType, saveType != SmSaveLocal, | 319 | SmsSaveYourself( c->connection(), saveType, saveType != SmSaveLocal, | ||
320 | saveType != SmSaveLocal ? SmInteractStyleAny : SmInteractStyleNone, | 320 | saveType != SmSaveLocal ? SmInteractStyleAny : SmInteractStyleNone, | ||
321 | false ); | 321 | false ); | ||
322 | } | 322 | } | ||
323 | } | 323 | } | ||
324 | } | 324 | } | ||
325 | 325 | | |||
Show All 23 Lines | |||||
349 | { | 349 | { | ||
350 | client->waitForPhase2 = true; | 350 | client->waitForPhase2 = true; | ||
351 | client->wasPhase2 = true; | 351 | client->wasPhase2 = true; | ||
352 | completeShutdownOrCheckpoint(); | 352 | completeShutdownOrCheckpoint(); | ||
353 | if( isWM( client ) && wmPhase1WaitingCount > 0 ) { | 353 | if( isWM( client ) && wmPhase1WaitingCount > 0 ) { | ||
354 | --wmPhase1WaitingCount; | 354 | --wmPhase1WaitingCount; | ||
355 | // WM finished its phase1 and requests phase2, save the rest | 355 | // WM finished its phase1 and requests phase2, save the rest | ||
356 | if( wmPhase1WaitingCount == 0 ) { | 356 | if( wmPhase1WaitingCount == 0 ) { | ||
357 | foreach( KSMClient* c, clients ) | 357 | for ( KSMClient* c : qAsConst(clients) ) | ||
358 | if( !isWM( c )) | 358 | if( !isWM( c )) | ||
359 | SmsSaveYourself( c->connection(), saveType, saveType != SmSaveLocal, | 359 | SmsSaveYourself( c->connection(), saveType, saveType != SmSaveLocal, | ||
360 | saveType != SmSaveLocal ? SmInteractStyleAny : SmInteractStyleNone, | 360 | saveType != SmSaveLocal ? SmInteractStyleAny : SmInteractStyleNone, | ||
361 | false ); | 361 | false ); | ||
362 | } | 362 | } | ||
363 | } | 363 | } | ||
364 | } | 364 | } | ||
365 | 365 | | |||
366 | void KSMServer::handlePendingInteractions() | 366 | void KSMServer::handlePendingInteractions() | ||
367 | { | 367 | { | ||
368 | if ( clientInteracting ) | 368 | if ( clientInteracting ) | ||
369 | return; | 369 | return; | ||
370 | 370 | | |||
371 | foreach( KSMClient* c, clients ) { | 371 | for ( KSMClient* c : qAsConst(clients) ) { | ||
372 | if ( c->pendingInteraction ) { | 372 | if ( c->pendingInteraction ) { | ||
373 | clientInteracting = c; | 373 | clientInteracting = c; | ||
374 | c->pendingInteraction = false; | 374 | c->pendingInteraction = false; | ||
375 | break; | 375 | break; | ||
376 | } | 376 | } | ||
377 | } | 377 | } | ||
378 | if ( clientInteracting ) { | 378 | if ( clientInteracting ) { | ||
379 | endProtection(); | 379 | endProtection(); | ||
Show All 13 Lines | 391 | if ( state == ClosingSubSession ) { | |||
393 | clientsToSave.clear(); | 393 | clientsToSave.clear(); | ||
394 | emit subSessionCloseCanceled(); | 394 | emit subSessionCloseCanceled(); | ||
395 | } else { | 395 | } else { | ||
396 | Solid::PowerManagement::stopSuppressingSleep(inhibitCookie); | 396 | Solid::PowerManagement::stopSuppressingSleep(inhibitCookie); | ||
397 | qCDebug(KSMSERVER) << "Client " << c->program() << " (" << c->clientId() << ") canceled shutdown."; | 397 | qCDebug(KSMSERVER) << "Client " << c->program() << " (" << c->clientId() << ") canceled shutdown."; | ||
398 | KNotification::event( QStringLiteral( "cancellogout" ), | 398 | KNotification::event( QStringLiteral( "cancellogout" ), | ||
399 | i18n( "Logout canceled by '%1'", c->program()), | 399 | i18n( "Logout canceled by '%1'", c->program()), | ||
400 | QPixmap() , nullptr , KNotification::DefaultEvent ); | 400 | QPixmap() , nullptr , KNotification::DefaultEvent ); | ||
401 | foreach( KSMClient* c, clients ) { | 401 | for ( KSMClient* c : qAsConst(clients) ) { | ||
402 | SmsShutdownCancelled( c->connection() ); | 402 | SmsShutdownCancelled( c->connection() ); | ||
403 | if( c->saveYourselfDone ) { | 403 | if( c->saveYourselfDone ) { | ||
404 | // Discard also saved state. | 404 | // Discard also saved state. | ||
405 | QStringList discard = c->discardCommand(); | 405 | QStringList discard = c->discardCommand(); | ||
406 | if( !discard.isEmpty()) | 406 | if( !discard.isEmpty()) | ||
407 | executeCommand( discard ); | 407 | executeCommand( discard ); | ||
408 | } | 408 | } | ||
409 | } | 409 | } | ||
Show All 23 Lines | |||||
433 | Internal protection slot, invoked when clients do not react during | 433 | Internal protection slot, invoked when clients do not react during | ||
434 | shutdown. | 434 | shutdown. | ||
435 | */ | 435 | */ | ||
436 | void KSMServer::protectionTimeout() | 436 | void KSMServer::protectionTimeout() | ||
437 | { | 437 | { | ||
438 | if ( ( state != Shutdown && state != Checkpoint && state != ClosingSubSession ) || clientInteracting ) | 438 | if ( ( state != Shutdown && state != Checkpoint && state != ClosingSubSession ) || clientInteracting ) | ||
439 | return; | 439 | return; | ||
440 | 440 | | |||
441 | foreach( KSMClient* c, clients ) { | 441 | for ( KSMClient* c : qAsConst(clients) ) { | ||
442 | if ( !c->saveYourselfDone && !c->waitForPhase2 ) { | 442 | if ( !c->saveYourselfDone && !c->waitForPhase2 ) { | ||
443 | qCDebug(KSMSERVER) << "protectionTimeout: client " << c->program() << "(" << c->clientId() << ")"; | 443 | qCDebug(KSMSERVER) << "protectionTimeout: client " << c->program() << "(" << c->clientId() << ")"; | ||
444 | c->saveYourselfDone = true; | 444 | c->saveYourselfDone = true; | ||
445 | } | 445 | } | ||
446 | } | 446 | } | ||
447 | completeShutdownOrCheckpoint(); | 447 | completeShutdownOrCheckpoint(); | ||
448 | startProtection(); | 448 | startProtection(); | ||
449 | } | 449 | } | ||
450 | 450 | | |||
451 | void KSMServer::completeShutdownOrCheckpoint() | 451 | void KSMServer::completeShutdownOrCheckpoint() | ||
452 | { | 452 | { | ||
453 | qCDebug(KSMSERVER) << "completeShutdownOrCheckpoint called"; | 453 | qCDebug(KSMSERVER) << "completeShutdownOrCheckpoint called"; | ||
454 | if ( state != Shutdown && state != Checkpoint && state != ClosingSubSession ) | 454 | if ( state != Shutdown && state != Checkpoint && state != ClosingSubSession ) | ||
455 | return; | 455 | return; | ||
456 | 456 | | |||
457 | QList<KSMClient*> pendingClients; | 457 | QList<KSMClient*> pendingClients; | ||
458 | if (state == ClosingSubSession) | 458 | if (state == ClosingSubSession) | ||
459 | pendingClients = clientsToSave; | 459 | pendingClients = clientsToSave; | ||
460 | else | 460 | else | ||
461 | pendingClients = clients; | 461 | pendingClients = clients; | ||
462 | 462 | | |||
463 | foreach( KSMClient* c, pendingClients ) { | 463 | for ( KSMClient* c : qAsConst(pendingClients) ) { | ||
464 | if ( !c->saveYourselfDone && !c->waitForPhase2 ) | 464 | if ( !c->saveYourselfDone && !c->waitForPhase2 ) | ||
465 | return; // not done yet | 465 | return; // not done yet | ||
466 | } | 466 | } | ||
467 | 467 | | |||
468 | // do phase 2 | 468 | // do phase 2 | ||
469 | bool waitForPhase2 = false; | 469 | bool waitForPhase2 = false; | ||
470 | foreach( KSMClient* c, pendingClients ) { | 470 | for ( KSMClient* c : qAsConst(pendingClients) ) { | ||
471 | if ( !c->saveYourselfDone && c->waitForPhase2 ) { | 471 | if ( !c->saveYourselfDone && c->waitForPhase2 ) { | ||
472 | c->waitForPhase2 = false; | 472 | c->waitForPhase2 = false; | ||
473 | SmsSaveYourselfPhase2( c->connection() ); | 473 | SmsSaveYourselfPhase2( c->connection() ); | ||
474 | waitForPhase2 = true; | 474 | waitForPhase2 = true; | ||
475 | } | 475 | } | ||
476 | } | 476 | } | ||
477 | if ( waitForPhase2 ) | 477 | if ( waitForPhase2 ) | ||
478 | return; | 478 | return; | ||
Show All 17 Lines | 495 | QTimer::singleShot(5000, this, [=]{ | |||
496 | if (state == WaitingForKNotify) { | 496 | if (state == WaitingForKNotify) { | ||
497 | n->deleteLater(); | 497 | n->deleteLater(); | ||
498 | startKilling(); | 498 | startKilling(); | ||
499 | } | 499 | } | ||
500 | }); | 500 | }); | ||
501 | createLogoutEffectWidget(); | 501 | createLogoutEffectWidget(); | ||
502 | 502 | | |||
503 | } else if ( state == Checkpoint ) { | 503 | } else if ( state == Checkpoint ) { | ||
504 | foreach( KSMClient* c, clients ) { | 504 | for ( KSMClient* c : qAsConst(clients) ) { | ||
505 | SmsSaveComplete( c->connection()); | 505 | SmsSaveComplete( c->connection()); | ||
506 | } | 506 | } | ||
507 | state = Idle; | 507 | state = Idle; | ||
508 | } else { //ClosingSubSession | 508 | } else { //ClosingSubSession | ||
509 | startKillingSubSession(); | 509 | startKillingSubSession(); | ||
510 | } | 510 | } | ||
511 | 511 | | |||
512 | } | 512 | } | ||
513 | 513 | | |||
514 | void KSMServer::startKilling() | 514 | void KSMServer::startKilling() | ||
515 | { | 515 | { | ||
516 | qCDebug(KSMSERVER) << "Starting killing clients"; | 516 | qCDebug(KSMSERVER) << "Starting killing clients"; | ||
517 | if (state == Killing) { | 517 | if (state == Killing) { | ||
518 | // we are already killing | 518 | // we are already killing | ||
519 | return; | 519 | return; | ||
520 | } | 520 | } | ||
521 | // kill all clients | 521 | // kill all clients | ||
522 | state = Killing; | 522 | state = Killing; | ||
523 | foreach( KSMClient* c, clients ) { | 523 | for ( KSMClient* c : qAsConst(clients) ) { | ||
524 | if( isWM( c )) // kill the WM as the last one in order to reduce flicker | 524 | if( isWM( c )) // kill the WM as the last one in order to reduce flicker | ||
525 | continue; | 525 | continue; | ||
526 | qCDebug(KSMSERVER) << "startKilling: client " << c->program() << "(" << c->clientId() << ")"; | 526 | qCDebug(KSMSERVER) << "startKilling: client " << c->program() << "(" << c->clientId() << ")"; | ||
527 | SmsDie( c->connection() ); | 527 | SmsDie( c->connection() ); | ||
528 | } | 528 | } | ||
529 | 529 | | |||
530 | qCDebug(KSMSERVER) << " We killed all clients. We have now clients.count()=" << | 530 | qCDebug(KSMSERVER) << " We killed all clients. We have now clients.count()=" << | ||
531 | clients.count() << endl; | 531 | clients.count() << endl; | ||
532 | completeKilling(); | 532 | completeKilling(); | ||
533 | QTimer::singleShot( 10000, this, &KSMServer::timeoutQuit ); | 533 | QTimer::singleShot( 10000, this, &KSMServer::timeoutQuit ); | ||
534 | } | 534 | } | ||
535 | 535 | | |||
536 | void KSMServer::completeKilling() | 536 | void KSMServer::completeKilling() | ||
537 | { | 537 | { | ||
538 | qCDebug(KSMSERVER) << "KSMServer::completeKilling clients.count()=" << | 538 | qCDebug(KSMSERVER) << "KSMServer::completeKilling clients.count()=" << | ||
539 | clients.count() << endl; | 539 | clients.count() << endl; | ||
540 | if( state == Killing ) { | 540 | if( state == Killing ) { | ||
541 | bool wait = false; | 541 | bool wait = false; | ||
542 | foreach( KSMClient* c, clients ) { | 542 | for ( KSMClient* c : qAsConst(clients) ) { | ||
543 | if( isWM( c )) | 543 | if( isWM( c )) | ||
544 | continue; | 544 | continue; | ||
545 | wait = true; // still waiting for clients to go away | 545 | wait = true; // still waiting for clients to go away | ||
546 | } | 546 | } | ||
547 | if( wait ) | 547 | if( wait ) | ||
548 | return; | 548 | return; | ||
549 | killWM(); | 549 | killWM(); | ||
550 | } | 550 | } | ||
551 | } | 551 | } | ||
552 | 552 | | |||
553 | void KSMServer::killWM() | 553 | void KSMServer::killWM() | ||
554 | { | 554 | { | ||
555 | if( state != Killing ) | 555 | if( state != Killing ) | ||
556 | return; | 556 | return; | ||
557 | delete logoutEffectWidget; | 557 | delete logoutEffectWidget; | ||
558 | 558 | | |||
559 | qCDebug(KSMSERVER) << "Starting killing WM"; | 559 | qCDebug(KSMSERVER) << "Starting killing WM"; | ||
560 | state = KillingWM; | 560 | state = KillingWM; | ||
561 | bool iswm = false; | 561 | bool iswm = false; | ||
562 | foreach( KSMClient* c, clients ) { | 562 | for ( KSMClient* c : qAsConst(clients) ) { | ||
563 | if( isWM( c )) { | 563 | if( isWM( c )) { | ||
564 | iswm = true; | 564 | iswm = true; | ||
565 | qCDebug(KSMSERVER) << "killWM: client " << c->program() << "(" << c->clientId() << ")"; | 565 | qCDebug(KSMSERVER) << "killWM: client " << c->program() << "(" << c->clientId() << ")"; | ||
566 | SmsDie( c->connection() ); | 566 | SmsDie( c->connection() ); | ||
567 | } | 567 | } | ||
568 | } | 568 | } | ||
569 | if( iswm ) { | 569 | if( iswm ) { | ||
570 | completeKillingWM(); | 570 | completeKillingWM(); | ||
Show All 16 Lines | |||||
587 | // shutdown is fully complete | 587 | // shutdown is fully complete | ||
588 | void KSMServer::killingCompleted() | 588 | void KSMServer::killingCompleted() | ||
589 | { | 589 | { | ||
590 | qApp->quit(); | 590 | qApp->quit(); | ||
591 | } | 591 | } | ||
592 | 592 | | |||
593 | void KSMServer::timeoutQuit() | 593 | void KSMServer::timeoutQuit() | ||
594 | { | 594 | { | ||
595 | foreach( KSMClient* c, clients ) { | 595 | for ( KSMClient* c : qAsConst(clients) ) { | ||
596 | qCWarning(KSMSERVER) << "SmsDie timeout, client " << c->program() << "(" << c->clientId() << ")" ; | 596 | qCWarning(KSMSERVER) << "SmsDie timeout, client " << c->program() << "(" << c->clientId() << ")" ; | ||
597 | } | 597 | } | ||
598 | killWM(); | 598 | killWM(); | ||
599 | } | 599 | } | ||
600 | 600 | | |||
601 | void KSMServer::timeoutWMQuit() | 601 | void KSMServer::timeoutWMQuit() | ||
602 | { | 602 | { | ||
603 | if( state == KillingWM ) { | 603 | if( state == KillingWM ) { | ||
Show All 33 Lines | 629 | { | |||
637 | saveSession = true; | 637 | saveSession = true; | ||
638 | sessionGroup = QStringLiteral( "SubSession: " ) + name; | 638 | sessionGroup = QStringLiteral( "SubSession: " ) + name; | ||
639 | 639 | | |||
640 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | 640 | #ifndef NO_LEGACY_SESSION_MANAGEMENT | ||
641 | //performLegacySessionSave(); FIXME | 641 | //performLegacySessionSave(); FIXME | ||
642 | #endif | 642 | #endif | ||
643 | 643 | | |||
644 | startProtection(); | 644 | startProtection(); | ||
645 | foreach( KSMClient* c, clients ) { | 645 | for ( KSMClient* c : qAsConst(clients) ) { | ||
646 | if (saveAndClose.contains(QString::fromLocal8Bit(c->clientId()))) { | 646 | if (saveAndClose.contains(QString::fromLocal8Bit(c->clientId()))) { | ||
647 | c->resetState(); | 647 | c->resetState(); | ||
648 | SmsSaveYourself( c->connection(), saveType, | 648 | SmsSaveYourself( c->connection(), saveType, | ||
649 | true, SmInteractStyleAny, false ); | 649 | true, SmInteractStyleAny, false ); | ||
650 | clientsToSave << c; | 650 | clientsToSave << c; | ||
651 | clientsToKill << c; | 651 | clientsToKill << c; | ||
652 | } else if (saveOnly.contains(QString::fromLocal8Bit(c->clientId()))) { | 652 | } else if (saveOnly.contains(QString::fromLocal8Bit(c->clientId()))) { | ||
653 | c->resetState(); | 653 | c->resetState(); | ||
654 | SmsSaveYourself( c->connection(), saveType, | 654 | SmsSaveYourself( c->connection(), saveType, | ||
655 | true, SmInteractStyleAny, false ); | 655 | true, SmInteractStyleAny, false ); | ||
656 | clientsToSave << c; | 656 | clientsToSave << c; | ||
657 | } | 657 | } | ||
658 | } | 658 | } | ||
659 | completeShutdownOrCheckpoint(); | 659 | completeShutdownOrCheckpoint(); | ||
660 | } | 660 | } | ||
661 | 661 | | |||
662 | void KSMServer::startKillingSubSession() | 662 | void KSMServer::startKillingSubSession() | ||
663 | { | 663 | { | ||
664 | qCDebug(KSMSERVER) << "Starting killing clients"; | 664 | qCDebug(KSMSERVER) << "Starting killing clients"; | ||
665 | // kill all clients | 665 | // kill all clients | ||
666 | state = KillingSubSession; | 666 | state = KillingSubSession; | ||
667 | foreach( KSMClient* c, clientsToKill ) { | 667 | for ( KSMClient* c : qAsConst(clientsToKill) ) { | ||
668 | qCDebug(KSMSERVER) << "completeShutdown: client " << c->program() << "(" << c->clientId() << ")"; | 668 | qCDebug(KSMSERVER) << "completeShutdown: client " << c->program() << "(" << c->clientId() << ")"; | ||
669 | SmsDie( c->connection() ); | 669 | SmsDie( c->connection() ); | ||
670 | } | 670 | } | ||
671 | 671 | | |||
672 | qCDebug(KSMSERVER) << " We killed some clients. We have now clients.count()=" << | 672 | qCDebug(KSMSERVER) << " We killed some clients. We have now clients.count()=" << | ||
673 | clients.count() << endl; | 673 | clients.count() << endl; | ||
674 | completeKillingSubSession(); | 674 | completeKillingSubSession(); | ||
675 | QTimer::singleShot( 10000, this, &KSMServer::signalSubSessionClosed ); | 675 | QTimer::singleShot( 10000, this, &KSMServer::signalSubSessionClosed ); | ||
676 | } | 676 | } | ||
677 | 677 | | |||
678 | void KSMServer::completeKillingSubSession() | 678 | void KSMServer::completeKillingSubSession() | ||
679 | { | 679 | { | ||
680 | qCDebug(KSMSERVER) << "KSMServer::completeKillingSubSession clients.count()=" << | 680 | qCDebug(KSMSERVER) << "KSMServer::completeKillingSubSession clients.count()=" << | ||
681 | clients.count() << endl; | 681 | clients.count() << endl; | ||
682 | if( state == KillingSubSession ) { | 682 | if( state == KillingSubSession ) { | ||
683 | bool wait = false; | 683 | bool wait = false; | ||
684 | foreach( KSMClient* c, clientsToKill ) { | 684 | for( KSMClient* c : qAsConst(clientsToKill )) { | ||
685 | if( isWM( c )) | 685 | if( isWM( c )) | ||
686 | continue; | 686 | continue; | ||
687 | wait = true; // still waiting for clients to go away | 687 | wait = true; // still waiting for clients to go away | ||
688 | } | 688 | } | ||
689 | if( wait ) | 689 | if( wait ) | ||
690 | return; | 690 | return; | ||
691 | signalSubSessionClosed(); | 691 | signalSubSessionClosed(); | ||
692 | } | 692 | } | ||
Show All 14 Lines |