author | drw <drw> | 2002-12-20 02:17:55 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-20 02:17:55 (UTC) |
commit | 9328bf79f49294e14c1753c9ee17ddd2985c1969 (patch) (unidiff) | |
tree | b0c9fa3e990b45cbfc9fb7fb33da73b9f6477df9 | |
parent | 3e556ed5f8c8b1236b9c6155b609930103d17b21 (diff) | |
download | opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.zip opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.gz opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.bz2 |
Fix to prevent segfault when no process/module is selected in list.
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 7 |
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 | |||
@@ -109,32 +109,37 @@ void ModulesInfo::updateData() | |||
109 | break; | 109 | break; |
110 | 110 | ||
111 | QString qmodname = QString( modname ); | 111 | QString qmodname = QString( modname ); |
112 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 112 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
113 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 113 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
114 | QString qusage = QString( usage ); | 114 | QString qusage = QString( usage ); |
115 | 115 | ||
116 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 116 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
117 | } | 117 | } |
118 | 118 | ||
119 | fclose( procfile ); | 119 | fclose( procfile ); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void ModulesInfo::slotSendClicked() | 123 | void ModulesInfo::slotSendClicked() |
124 | { | 124 | { |
125 | if ( !ModulesView->currentItem() ) | ||
126 | { | ||
127 | return; | ||
128 | } | ||
129 | |||
125 | QString capstr = tr( "You really want to execute\n" ); | 130 | QString capstr = tr( "You really want to execute\n" ); |
126 | capstr.append( CommandCB->currentText() ); | 131 | capstr.append( CommandCB->currentText() ); |
127 | capstr.append( "\nfor this module?" ); | 132 | capstr.append( "\nfor this module?" ); |
128 | 133 | ||
129 | QString modname = ModulesView->currentItem()->text( 0 ); | 134 | QString modname = ModulesView->currentItem()->text( 0 ); |
130 | 135 | ||
131 | if ( QMessageBox::warning( this, modname, capstr, | 136 | if ( QMessageBox::warning( this, modname, capstr, |
132 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 137 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
133 | { | 138 | { |
134 | QString command = "/sbin/"; | 139 | QString command = "/sbin/"; |
135 | command.append( CommandCB->currentText() ); | 140 | command.append( CommandCB->currentText() ); |
136 | command.append( " " ); | 141 | command.append( " " ); |
137 | command.append( modname ); | 142 | command.append( modname ); |
138 | 143 | ||
139 | FILE* stream = popen( command, "r" ); | 144 | FILE* stream = popen( command, "r" ); |
140 | if ( stream ) | 145 | if ( stream ) |
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 | |||
@@ -131,37 +131,42 @@ void ProcessInfo::updateData() | |||
131 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 131 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
132 | processtime = processtime.rightJustify( 9, ' ' ); | 132 | processtime = processtime.rightJustify( 9, ' ' ); |
133 | fclose( procfile ); | 133 | fclose( procfile ); |
134 | 134 | ||
135 | ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 135 | ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | delete proclist; | 141 | delete proclist; |
142 | delete procdir; | 142 | delete procdir; |
143 | } | 143 | } |
144 | 144 | ||
145 | void ProcessInfo::slotSendClicked() | 145 | void ProcessInfo::slotSendClicked() |
146 | { | 146 | { |
147 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
148 | if ( !currprocess ) | ||
149 | { | ||
150 | return; | ||
151 | } | ||
152 | |||
147 | QString capstr = tr( "You really want to send\n" ); | 153 | QString capstr = tr( "You really want to send\n" ); |
148 | capstr.append( SignalCB->currentText() ); | 154 | capstr.append( SignalCB->currentText() ); |
149 | capstr.append( "\nto this process?" ); | 155 | capstr.append( "\nto this process?" ); |
150 | 156 | ||
151 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
152 | 157 | ||
153 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 158 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
154 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 159 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
155 | { | 160 | { |
156 | QString sigstr = SignalCB->currentText(); | 161 | QString sigstr = SignalCB->currentText(); |
157 | sigstr.truncate(2); | 162 | sigstr.truncate(2); |
158 | int sigid = sigstr.toUInt(); | 163 | int sigid = sigstr.toUInt(); |
159 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) | 164 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) |
160 | { | 165 | { |
161 | hide(); | 166 | hide(); |
162 | } | 167 | } |
163 | } | 168 | } |
164 | 169 | ||
165 | } | 170 | } |
166 | 171 | ||
167 | void ProcessInfo::viewProcess( QListViewItem *process ) | 172 | void ProcessInfo::viewProcess( QListViewItem *process ) |