[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkde-workspace/KDE/4=2E6=5D_libs/ksysguard/processui?=
From: John Tapsell <johnflux () gmail ! com>
Date: 2011-03-24 0:21:10
Message-ID: 20110324002110.A3D18A60B0 () git ! kde ! org
[Download RAW message or body]
Git commit 973daba7fb809f7487d7e007bf932c381f28ca31 by John Tapsell.
Committed on 24/03/2011 at 01:08.
Pushed by johnflux into branch 'KDE/4.6'.
Fix crash when renicing a process, and it is killed
BUG:254772
M +42 -32 libs/ksysguard/processui/ksysguardprocesslist.cpp
http://commits.kde.org/kde-workspace/973daba7fb809f7487d7e007bf932c381f28ca31
diff --git a/libs/ksysguard/processui/ksysguardprocesslist.cpp \
b/libs/ksysguard/processui/ksysguardprocesslist.cpp index b0aa80a..a37dca0 100644
--- a/libs/ksysguard/processui/ksysguardprocesslist.cpp
+++ b/libs/ksysguard/processui/ksysguardprocesslist.cpp
@@ -1011,41 +1011,51 @@ QList<KSysGuard::Process *> \
KSysGuardProcessList::selectedProcesses() const
void KSysGuardProcessList::reniceSelectedProcesses()
{
- QList<KSysGuard::Process *> processes = selectedProcesses();
- QStringList selectedAsStrings;
-
- if (processes.isEmpty())
+ QList<long long> pids;
+ QPointer<ReniceDlg> reniceDlg;
{
- KMessageBox::sorry(this, i18n("You must select a process first."));
- return;
- }
+ QList<KSysGuard::Process *> processes = selectedProcesses();
+ QStringList selectedAsStrings;
- int sched = -2;
- int iosched = -2;
- foreach(KSysGuard::Process *process, processes) {
- selectedAsStrings << d->mModel.getStringForProcess(process);
- if(sched == -2) sched = (int)process->scheduler;
- else if(sched != -1 && sched != (int)process->scheduler) sched = -1; //If \
two processes have different schedulers, disable the cpu scheduler \
stuff
- if(iosched == -2) iosched = (int)process->ioPriorityClass;
- else if(iosched != -1 && iosched != (int)process->ioPriorityClass) iosched = \
-1; //If two processes have different schedulers, disable the cpu scheduler stuff + \
if (processes.isEmpty()) { + KMessageBox::sorry(this, i18n("You must \
select a process first.")); + return;
+ }
- }
+ int sched = -2;
+ int iosched = -2;
+ foreach(KSysGuard::Process *process, processes) {
+ pids << process->pid;
+ selectedAsStrings << d->mModel.getStringForProcess(process);
+ if(sched == -2) sched = (int)process->scheduler;
+ else if(sched != -1 && sched != (int)process->scheduler) sched = -1; \
//If two processes have different schedulers, disable the cpu scheduler stuff + \
if(iosched == -2) iosched = (int)process->ioPriorityClass; + else \
if(iosched != -1 && iosched != (int)process->ioPriorityClass) iosched = -1; //If two \
processes have different schedulers, disable the cpu scheduler stuff
- int firstPriority = processes.first()->niceLevel;
- int firstIOPriority = processes.first()->ioniceLevel;
+ }
+ int firstPriority = processes.first()->niceLevel;
+ int firstIOPriority = processes.first()->ioniceLevel;
- bool supportsIoNice = d->mModel.processController()->supportsIoNiceness();
- if(!supportsIoNice) { iosched = -2; firstIOPriority = -2; }
- QPointer<ReniceDlg> reniceDlg = new ReniceDlg(d->mUi->treeView, \
selectedAsStrings, firstPriority, sched, firstIOPriority, iosched);
- if(reniceDlg->exec() == QDialog::Rejected) {
- delete reniceDlg;
- return;
+ bool supportsIoNice = d->mModel.processController()->supportsIoNiceness();
+ if(!supportsIoNice) { iosched = -2; firstIOPriority = -2; }
+ reniceDlg = new ReniceDlg(d->mUi->treeView, selectedAsStrings, \
firstPriority, sched, firstIOPriority, iosched); + if(reniceDlg->exec() == \
QDialog::Rejected) { + delete reniceDlg;
+ return;
+ }
}
+ //Because we've done into ReniceDlg, which calls processEvents etc, our \
processes list is no + //longer valid
+
QList<long long> renicePids;
QList<long long> changeCPUSchedulerPids;
QList<long long> changeIOSchedulerPids;
- foreach(KSysGuard::Process *process, processes) {
+ foreach (long long pid, pids) {
+ KSysGuard::Process *process = d->mModel.getProcess(pid);
+ if (!process)
+ continue;
+
switch(reniceDlg->newCPUSched) {
case -2:
case -1: //Invalid, not changed etc.
@@ -1053,16 +1063,16 @@ void KSysGuardProcessList::reniceSelectedProcesses()
case KSysGuard::Process::Other:
case KSysGuard::Process::Fifo:
if(reniceDlg->newCPUSched != (int)process->scheduler) {
- changeCPUSchedulerPids << process->pid;
- renicePids << process->pid;
+ changeCPUSchedulerPids << pid;
+ renicePids << pid;
} else if(reniceDlg->newCPUPriority != process->niceLevel)
- renicePids << process->pid;
+ renicePids << pid;
break;
case KSysGuard::Process::RoundRobin:
case KSysGuard::Process::Batch:
if(reniceDlg->newCPUSched != (int)process->scheduler || \
reniceDlg->newCPUPriority != process->niceLevel) {
- changeCPUSchedulerPids << process->pid;
+ changeCPUSchedulerPids << pid;
}
break;
}
@@ -1074,12 +1084,12 @@ void KSysGuardProcessList::reniceSelectedProcesses()
if(reniceDlg->newIOSched != (int)process->ioPriorityClass) {
// Unfortunately linux doesn't actually let us set the \
ioniceness back to none after being set to something else
if(process->ioPriorityClass != KSysGuard::Process::BestEffort || \
reniceDlg->newIOPriority != process->ioniceLevel)
- changeIOSchedulerPids << process->pid;
+ changeIOSchedulerPids << pid;
}
break;
case KSysGuard::Process::Idle:
if(reniceDlg->newIOSched != (int)process->ioPriorityClass) {
- changeIOSchedulerPids << process->pid;
+ changeIOSchedulerPids << pid;
}
break;
case KSysGuard::Process::BestEffort:
@@ -1087,7 +1097,7 @@ void KSysGuardProcessList::reniceSelectedProcesses()
break; //Don't set to BestEffort if it's on None and the \
nicelevel wouldn't change case KSysGuard::Process::RealTime:
if(reniceDlg->newIOSched != (int)process->ioPriorityClass || \
reniceDlg->newIOPriority != process->ioniceLevel) {
- changeIOSchedulerPids << process->pid;
+ changeIOSchedulerPids << pid;
}
break;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic