summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-01-26 22:45:27 (UTC)
committer kergoth <kergoth>2003-01-26 22:45:27 (UTC)
commit954ff2a858b34a8249314340f799f0a74426d59c (patch) (unidiff)
treef0b738dceaec14bba0347151db4f372d25cdf8e8
parent4ce67fbdfb5e82bbde3a8963d3e956567438689d (diff)
downloadopie-954ff2a858b34a8249314340f799f0a74426d59c.zip
opie-954ff2a858b34a8249314340f799f0a74426d59c.tar.gz
opie-954ff2a858b34a8249314340f799f0a74426d59c.tar.bz2
Added two missing dir.exists() checks, without which a segfault occurs if m_currentDir doesnt exist.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc148
1 files changed, 76 insertions, 72 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 6a6a300..7481360 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1173,127 +1173,131 @@ void OFileSelector::slotHome()
1173} 1173}
1174void OFileSelector::slotDoc() 1174void OFileSelector::slotDoc()
1175{ 1175{
1176 cd(QPEApplication::documentDir() ); 1176 cd(QPEApplication::documentDir() );
1177} 1177}
1178void OFileSelector::slotNavigate( ) 1178void OFileSelector::slotNavigate( )
1179{ 1179{
1180 1180
1181} 1181}
1182// fill the View with life 1182// fill the View with life
1183void OFileSelector::reparse() 1183void OFileSelector::reparse()
1184{ 1184{
1185 if( m_selector == NORMAL ) 1185 if( m_selector == NORMAL )
1186 return; 1186 return;
1187 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) 1187 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL )
1188 m_View->clear(); 1188 m_View->clear();
1189 else // custom view 1189 else // custom view
1190 ; // currentView()->clear(); 1190 ; // currentView()->clear();
1191 if( m_shChooser) 1191 if( m_shChooser)
1192 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 1192 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
1193 1193
1194 QString currentMimeType; 1194 QString currentMimeType;
1195 // let's update the mimetype 1195 // let's update the mimetype
1196 if( m_autoMime ){ 1196 if( m_autoMime ){
1197 m_mimetypes.clear(); 1197 m_mimetypes.clear();
1198 // ok we can change mimetype so we need to be able to give a selection 1198 // ok we can change mimetype so we need to be able to give a selection
1199 if( m_shChooser ) { 1199 if( m_shChooser ) {
1200 currentMimeType = m_mimeCheck->currentText(); 1200 currentMimeType = m_mimeCheck->currentText();
1201 m_mimeCheck->clear(); 1201 m_mimeCheck->clear();
1202 1202
1203 // let's find possible mimetypes 1203 // let's find possible mimetypes
1204 QDir dir( m_currentDir ); 1204 QDir dir( m_currentDir );
1205 dir.setFilter( QDir::Files | QDir::Readable ); 1205 if( dir.exists() ){
1206 dir.setSorting( QDir::Size ); 1206 dir.setFilter( QDir::Files | QDir::Readable );
1207 const QFileInfoList *list = dir.entryInfoList(); 1207 dir.setSorting( QDir::Size );
1208 QFileInfoListIterator it( *list ); 1208 const QFileInfoList *list = dir.entryInfoList();
1209 QFileInfo *fi; 1209 QFileInfoListIterator it( *list );
1210 while( (fi=it.current() ) ) { 1210 QFileInfo *fi;
1211 if( fi->extension() == QString::fromLatin1("desktop") ){ 1211 while( (fi=it.current() ) ) {
1212 ++it; 1212 if( fi->extension() == QString::fromLatin1("desktop") ){
1213 continue; 1213 ++it;
1214 } 1214 continue;
1215 MimeType type( fi->absFilePath() ); 1215 }
1216 if( !m_mimetypes.contains( type.id() ) ){ 1216 MimeType type( fi->absFilePath() );
1217 //qWarning("Type %s", type.id().latin1() ); 1217 if( !m_mimetypes.contains( type.id() ) ){
1218 m_mimetypes.insert( type.id(), type.id() ); 1218 //qWarning("Type %s", type.id().latin1() );
1219 } 1219 m_mimetypes.insert( type.id(), type.id() );
1220 }
1220 1221
1221 ++it; 1222 ++it;
1223 }
1224 // add them to the chooser
1225 updateMimeCheck();
1226 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1227 currentMimeType = m_mimeCheck->currentText();
1222 } 1228 }
1223 // add them to the chooser
1224 updateMimeCheck();
1225 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1226 currentMimeType = m_mimeCheck->currentText();
1227 } 1229 }
1228 }else { // no autoMime 1230 }else { // no autoMime
1229 // let the mimetype be set from out side the m_mimeCheck FEATURE 1231 // let the mimetype be set from out side the m_mimeCheck FEATURE
1230 1232
1231 if( m_shChooser ){ 1233 if( m_shChooser ){
1232 currentMimeType = m_mimeCheck->currentText(); 1234 currentMimeType = m_mimeCheck->currentText();
1233// updateMimeCheck(); 1235// updateMimeCheck();
1234 } 1236 }
1235 } 1237 }
1236 // now we got our mimetypes we can add the files 1238 // now we got our mimetypes we can add the files
1237 1239
1238 QDir dir( m_currentDir ); 1240 QDir dir( m_currentDir );
1239 1241
1240 int sort; 1242 if( dir.exists() ){
1241 if ( m_case ) 1243 int sort;
1242 sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); 1244 if ( m_case )
1243 else 1245 sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed);
1244 sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); 1246 else
1245 dir.setSorting( sort ); 1247 sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed);
1246 1248 dir.setSorting( sort );
1247 int filter; 1249
1248 if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ 1250 int filter;
1249 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1251 if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){
1250 }else 1252 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1251 filter = QDir::Files | QDir::Dirs | QDir::All; 1253 }else
1252 dir.setFilter( filter ); 1254 filter = QDir::Files | QDir::Dirs | QDir::All;
1253 1255 dir.setFilter( filter );
1254 // now go through all files 1256
1255 const QFileInfoList *list = dir.entryInfoList(); 1257 // now go through all files
1256 QFileInfoListIterator it( *list ); 1258 const QFileInfoList *list = dir.entryInfoList();
1257 QFileInfo *fi; 1259 QFileInfoListIterator it( *list );
1258 while( (fi=it.current() ) ){ 1260 QFileInfo *fi;
1259 //qWarning("True and only" ); 1261 while( (fi=it.current() ) ){
1260 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ 1262 //qWarning("True and only" );
1261 //qWarning(".. or ." ); 1263 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
1264 //qWarning(".. or ." );
1265 ++it;
1266 continue;
1267 }
1268 if( fi->isSymLink() ){
1269 QString file = fi->dirPath( true ) + "/" + fi->readLink();
1270 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
1271 QFileInfo info( file );
1272 if( !info.exists() ){
1273 addSymlink( currentMimeType, fi, TRUE );
1274 break;
1275 }else if( info.isDir() ){
1276 addDir( currentMimeType, fi, TRUE );
1277 break;
1278 }else if( info.isFile() ){
1279 addFile( currentMimeType, fi, TRUE );
1280 break;
1281 }else if( info.isSymLink() ){
1282 file = info.dirPath(true ) + "/" + info.readLink() ;
1283 break;
1284 }else if( i == 4){
1285 addSymlink( currentMimeType, fi );
1286 }
1287 } // off for loop
1288 }else if( fi->isDir() ){
1289 addDir( currentMimeType, fi );
1290 }else if( fi->isFile() ){
1291 addFile( currentMimeType, fi );
1292 }
1293 //qWarning( "%s", fi->fileName().latin1() );
1262 ++it; 1294 ++it;
1263 continue; 1295 } // of while loop
1264 } 1296 } // if ( dir.exists() )
1265 if( fi->isSymLink() ){
1266 QString file = fi->dirPath( true ) + "/" + fi->readLink();
1267 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
1268 QFileInfo info( file );
1269 if( !info.exists() ){
1270 addSymlink( currentMimeType, fi, TRUE );
1271 break;
1272 }else if( info.isDir() ){
1273 addDir( currentMimeType, fi, TRUE );
1274 break;
1275 }else if( info.isFile() ){
1276 addFile( currentMimeType, fi, TRUE );
1277 break;
1278 }else if( info.isSymLink() ){
1279 file = info.dirPath(true ) + "/" + info.readLink() ;
1280 break;
1281 }else if( i == 4){
1282 addSymlink( currentMimeType, fi );
1283 }
1284 } // off for loop
1285 }else if( fi->isDir() ){
1286 addDir( currentMimeType, fi );
1287 }else if( fi->isFile() ){
1288 addFile( currentMimeType, fi );
1289 }
1290 //qWarning( "%s", fi->fileName().latin1() );
1291 ++it;
1292 } // of while loop
1293 m_View->sort(); 1297 m_View->sort();
1294 if( m_shTool ){ 1298 if( m_shTool ){
1295 m_location->insertItem( m_currentDir ); 1299 m_location->insertItem( m_currentDir );
1296 1300
1297 } 1301 }
1298 // reenable painting and updates 1302 // reenable painting and updates
1299} 1303}