summaryrefslogtreecommitdiff
authordrw <drw>2002-12-20 02:17:55 (UTC)
committer drw <drw>2002-12-20 02:17:55 (UTC)
commit9328bf79f49294e14c1753c9ee17ddd2985c1969 (patch) (side-by-side diff)
treeb0c9fa3e990b45cbfc9fb7fb33da73b9f6477df9
parent3e556ed5f8c8b1236b9c6155b609930103d17b21 (diff)
downloadopie-9328bf79f49294e14c1753c9ee17ddd2985c1969.zip
opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.gz
opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.bz2
Fix to prevent segfault when no process/module is selected in list.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp5
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index 8b58fe9..29cce90 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -101,48 +101,53 @@ void ModulesInfo::updateData()
FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
if ( procfile )
{
while ( true ) {
int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
if ( success == EOF )
break;
QString qmodname = QString( modname );
QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
QString qusage = QString( usage );
( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
}
fclose( procfile );
}
}
void ModulesInfo::slotSendClicked()
{
+ if ( !ModulesView->currentItem() )
+ {
+ return;
+ }
+
QString capstr = tr( "You really want to execute\n" );
capstr.append( CommandCB->currentText() );
capstr.append( "\nfor this module?" );
QString modname = ModulesView->currentItem()->text( 0 );
if ( QMessageBox::warning( this, modname, capstr,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
{
QString command = "/sbin/";
command.append( CommandCB->currentText() );
command.append( " " );
command.append( modname );
FILE* stream = popen( command, "r" );
if ( stream )
pclose( stream );
}
}
void ModulesInfo::viewModules( QListViewItem *modules )
{
QString modname = modules->text( 0 );
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 35d7ba1..9a5446a 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -123,53 +123,58 @@ void ProcessInfo::updateData()
"%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u",
&pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
&majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
&itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
&kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
processnum = processnum.rightJustify( 5, ' ' );
QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
QString processstatus = QChar(state);
QString processtime = QString::number( ( utime + stime ) / 100 );
processtime = processtime.rightJustify( 9, ' ' );
fclose( procfile );
( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
}
}
}
}
delete proclist;
delete procdir;
}
void ProcessInfo::slotSendClicked()
{
+ QListViewItem *currprocess = ProcessView->currentItem();
+ if ( !currprocess )
+ {
+ return;
+ }
+
QString capstr = tr( "You really want to send\n" );
capstr.append( SignalCB->currentText() );
capstr.append( "\nto this process?" );
- QListViewItem *currprocess = ProcessView->currentItem();
if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
{
QString sigstr = SignalCB->currentText();
sigstr.truncate(2);
int sigid = sigstr.toUInt();
if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 )
{
hide();
}
}
}
void ProcessInfo::viewProcess( QListViewItem *process )
{
QString pid= process->text( 0 ).stripWhiteSpace();
QString command = process->text( 1 );
ProcessDtl->setCaption( pid + " - " + command );
FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
if ( statfile )
{
char line[81];