-rw-r--r-- | library/config.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/config.cpp b/library/config.cpp index b47c620..b28c771 100644 --- a/library/config.cpp +++ b/library/config.cpp | |||
@@ -512,24 +512,34 @@ void Config::read() | |||
512 | 512 | ||
513 | if ( !QFileInfo( filename ).exists() ) { | 513 | if ( !QFileInfo( filename ).exists() ) { |
514 | git = groups.end(); | 514 | git = groups.end(); |
515 | return; | 515 | return; |
516 | } | 516 | } |
517 | 517 | ||
518 | QFile f( filename ); | 518 | QFile f( filename ); |
519 | if ( !f.open( IO_ReadOnly ) ) { | 519 | if ( !f.open( IO_ReadOnly ) ) { |
520 | git = groups.end(); | 520 | git = groups.end(); |
521 | return; | 521 | return; |
522 | } | 522 | } |
523 | 523 | ||
524 | |||
525 | // hack to avoid problems if big files are passed to test | ||
526 | // if they are valid configs ( like passing a mp3 ... ) | ||
527 | // I just hope that there are no conf files > 100000 byte | ||
528 | // not the best solution, find something else later | ||
529 | if ( f.size() > 100000 ) { | ||
530 | return; | ||
531 | } | ||
532 | |||
533 | |||
524 | QTextStream s( &f ); | 534 | QTextStream s( &f ); |
525 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 535 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
526 | // The below should work, but doesn't in Qt 2.3.0 | 536 | // The below should work, but doesn't in Qt 2.3.0 |
527 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | 537 | s.setCodec( QTextCodec::codecForMib( 106 ) ); |
528 | #else | 538 | #else |
529 | s.setEncoding( QTextStream::UnicodeUTF8 ); | 539 | s.setEncoding( QTextStream::UnicodeUTF8 ); |
530 | #endif | 540 | #endif |
531 | 541 | ||
532 | QStringList list = QStringList::split('\n', s.read() ); | 542 | QStringList list = QStringList::split('\n', s.read() ); |
533 | f.close(); | 543 | f.close(); |
534 | 544 | ||
535 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 545 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |