author | zecke <zecke> | 2004-09-27 21:44:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-27 21:44:42 (UTC) |
commit | 9c8f2e26e05be9230ed960d4b4ed21dc658df33e (patch) (unidiff) | |
tree | f0c16477d1d25374fb0a983da786ef96839e7db5 | |
parent | ba463a1029d1c0ff553a3dc9bf544617289d95f0 (diff) | |
download | opie-9c8f2e26e05be9230ed960d4b4ed21dc658df33e.zip opie-9c8f2e26e05be9230ed960d4b4ed21dc658df33e.tar.gz opie-9c8f2e26e05be9230ed960d4b4ed21dc658df33e.tar.bz2 |
Do not crash due an empty image
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 4a2440a..110786a 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -1,26 +1,29 @@ | |||
1 | #include <time.h> | 1 | #include <time.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qpe/resource.h> | ||
4 | |||
5 | |||
3 | #include <qpainter.h> | 6 | #include <qpainter.h> |
4 | #include <qbitmap.h> | 7 | #include <qbitmap.h> |
5 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
6 | #include <qpixmap.h> | 9 | #include <qpixmap.h> |
7 | 10 | ||
8 | #include "resources.h" | 11 | #include "resources.h" |
9 | #include "netnode.h" | 12 | #include "netnode.h" |
10 | 13 | ||
11 | #include "asdevice.h" | 14 | #include "asdevice.h" |
12 | #include "asline.h" | 15 | #include "asline.h" |
13 | #include "asconnection.h" | 16 | #include "asconnection.h" |
14 | #include "asfullsetup.h" | 17 | #include "asfullsetup.h" |
15 | 18 | ||
16 | QString & deQuote( QString & X ) { | 19 | QString & deQuote( QString & X ) { |
17 | if( X[0] == '"' ) { | 20 | if( X[0] == '"' ) { |
18 | // remove end and trailing "" and \x -> x | 21 | // remove end and trailing "" and \x -> x |
19 | QChar R; | 22 | QChar R; |
20 | long idx; | 23 | long idx; |
21 | idx = X.length()-1; | 24 | idx = X.length()-1; |
22 | X = X.mid( 1, idx ); | 25 | X = X.mid( 1, idx ); |
23 | 26 | ||
24 | idx = 0; | 27 | idx = 0; |
25 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { | 28 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { |
26 | R = X.at( idx + 1 ); | 29 | R = X.at( idx + 1 ); |
@@ -232,48 +235,51 @@ ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | |||
232 | int NodeCollection::compareItems( QCollection::Item I1, | 235 | int NodeCollection::compareItems( QCollection::Item I1, |
233 | QCollection::Item I2 ) { | 236 | QCollection::Item I2 ) { |
234 | ANetNodeInstance * NNI1, * NNI2; | 237 | ANetNodeInstance * NNI1, * NNI2; |
235 | NNI1 = (ANetNodeInstance *)I1; | 238 | NNI1 = (ANetNodeInstance *)I1; |
236 | NNI2 = (ANetNodeInstance *)I2; | 239 | NNI2 = (ANetNodeInstance *)I2; |
237 | return strcmp( NNI1->name(), NNI2->name() ); | 240 | return strcmp( NNI1->name(), NNI2->name() ); |
238 | } | 241 | } |
239 | 242 | ||
240 | static char * State2PixmapTbl[] = { | 243 | static char * State2PixmapTbl[] = { |
241 | "NULL", // Unchecked : no pixmap | 244 | "NULL", // Unchecked : no pixmap |
242 | "check", // Unknown | 245 | "check", // Unknown |
243 | "delete", // unavailable | 246 | "delete", // unavailable |
244 | "disabled", // disabled | 247 | "disabled", // disabled |
245 | "off", // off | 248 | "off", // off |
246 | "disconnected", // available | 249 | "disconnected", // available |
247 | "connected" // up | 250 | "connected" // up |
248 | }; | 251 | }; |
249 | 252 | ||
250 | QPixmap NodeCollection::devicePixmap( void ) { | 253 | QPixmap NodeCollection::devicePixmap( void ) { |
251 | QPixmap pm = NSResources->getPixmap( | 254 | QPixmap pm = NSResources->getPixmap( |
252 | getToplevel()->nextNode()->pixmapName()+"-large"); | 255 | getToplevel()->nextNode()->pixmapName()+"-large"); |
253 | 256 | ||
254 | QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); | 257 | QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); |
255 | 258 | ||
259 | if( pm.isNull() || Mini.isNull() ) | ||
260 | return Resource::loadPixmap("Unknown"); | ||
261 | |||
256 | QPainter painter( &pm ); | 262 | QPainter painter( &pm ); |
257 | painter.drawPixmap( pm.width()-Mini.width(), | 263 | painter.drawPixmap( pm.width()-Mini.width(), |
258 | pm.height()-Mini.height(), | 264 | pm.height()-Mini.height(), |
259 | Mini ); | 265 | Mini ); |
260 | pm.setMask( pm.createHeuristicMask( TRUE ) ); | 266 | pm.setMask( pm.createHeuristicMask( TRUE ) ); |
261 | return pm; | 267 | return pm; |
262 | } | 268 | } |
263 | 269 | ||
264 | QPixmap NodeCollection::statePixmap( State_t S) { | 270 | QPixmap NodeCollection::statePixmap( State_t S) { |
265 | return NSResources->getPixmap( State2PixmapTbl[S] ); | 271 | return NSResources->getPixmap( State2PixmapTbl[S] ); |
266 | } | 272 | } |
267 | 273 | ||
268 | QString NodeCollection::stateName( State_t S) { | 274 | QString NodeCollection::stateName( State_t S) { |
269 | switch( S ) { | 275 | switch( S ) { |
270 | case Unknown : | 276 | case Unknown : |
271 | return qApp->translate( "networksettings2", "Unknown"); | 277 | return qApp->translate( "networksettings2", "Unknown"); |
272 | case Unavailable : | 278 | case Unavailable : |
273 | return qApp->translate( "networksettings2", "Unavailable"); | 279 | return qApp->translate( "networksettings2", "Unavailable"); |
274 | case Disabled : | 280 | case Disabled : |
275 | return qApp->translate( "networksettings2", "Disabled"); | 281 | return qApp->translate( "networksettings2", "Disabled"); |
276 | case Off : | 282 | case Off : |
277 | return qApp->translate( "networksettings2", "Off"); | 283 | return qApp->translate( "networksettings2", "Off"); |
278 | case Available : | 284 | case Available : |
279 | return qApp->translate( "networksettings2", "Available"); | 285 | return qApp->translate( "networksettings2", "Available"); |