Author: sh-sh-sh Date: Fri Oct 24 18:26:23 2008 New Revision: 52541 URL: http://svn.opensuse.org/viewcvs/yast?rev=52541&view=rev Log: Fixed bnc # 403367: Crash when searching for invalid regex Modified: trunk/qt-pkg/VERSION.cmake trunk/qt-pkg/package/yast2-qt-pkg.changes trunk/qt-pkg/src/YQPkgSearchFilterView.cc Modified: trunk/qt-pkg/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/VERSION.cmake?rev=52541&r1=52540&r2=52541&view=diff ============================================================================== --- trunk/qt-pkg/VERSION.cmake (original) +++ trunk/qt-pkg/VERSION.cmake Fri Oct 24 18:26:23 2008 @@ -1,3 +1,3 @@ SET(VERSION_MAJOR "2") SET(VERSION_MINOR "17") -SET(VERSION_PATCH "13") +SET(VERSION_PATCH "14") Modified: trunk/qt-pkg/package/yast2-qt-pkg.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/package/yast2-qt-pkg.changes?rev=52541&r1=52540&r2=52541&view=diff ============================================================================== --- trunk/qt-pkg/package/yast2-qt-pkg.changes (original) +++ trunk/qt-pkg/package/yast2-qt-pkg.changes Fri Oct 24 18:26:23 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Oct 24 18:25:17 CEST 2008 - sh@suse.de + +- Fixed bnc # 403367: Crash when searching for invalid regex +- V 2.17.4 + +------------------------------------------------------------------- Tue Oct 21 15:59:49 CEST 2008 - sh@suse.de - Fixed bnc #436783: Map Amusements/Teaching/* to Education Modified: trunk/qt-pkg/src/YQPkgSearchFilterView.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgSearchFilterView.cc?rev=52541&r1=52540&r2=52541&view=diff ============================================================================== --- trunk/qt-pkg/src/YQPkgSearchFilterView.cc (original) +++ trunk/qt-pkg/src/YQPkgSearchFilterView.cc Fri Oct 24 18:26:23 2008 @@ -28,11 +28,12 @@ #include <QProgressDialog> #include <QDateTime> #include <QKeyEvent> +#include <QMessageBox> -#include "zypp/PoolQuery.h" +#include <zypp/PoolQuery.h> #define YUILogComponent "qt-pkg" -#include "YUILog.h" +#include <YUILog.h> #include "YQPackageSelector.h" #include "YQPkgSearchFilterView.h" @@ -89,27 +90,27 @@ QGroupBox * gbox = new QGroupBox( _( "Search in" ), this ); Q_CHECK_PTR( gbox ); - layout->addWidget(gbox); - QVBoxLayout *vlayout = new QVBoxLayout; - gbox->setLayout(vlayout); + layout->addWidget( gbox ); + QVBoxLayout *vLayout = new QVBoxLayout; + gbox->setLayout( vLayout ); _searchInName = new QCheckBox( _( "&Name" ), gbox ); Q_CHECK_PTR( _searchInName ); - vlayout->addWidget(_searchInName); + vLayout->addWidget(_searchInName); _searchInSummary = new QCheckBox( _( "Su&mmary" ), gbox ); Q_CHECK_PTR( _searchInSummary ); - vlayout->addWidget(_searchInSummary); + vLayout->addWidget(_searchInSummary); _searchInDescription = new QCheckBox( _( "Descr&iption" ), gbox ); Q_CHECK_PTR( _searchInDescription ); - vlayout->addWidget(_searchInDescription); + vLayout->addWidget(_searchInDescription); - vlayout->addStretch(); + vLayout->addStretch(); // Intentionally NOT marking RPM tags for translation _searchInProvides = new QCheckBox( "RPM \"&Provides\"" , gbox ); Q_CHECK_PTR( _searchInProvides ); - vlayout->addWidget(_searchInProvides); + vLayout->addWidget(_searchInProvides); _searchInRequires = new QCheckBox( "RPM \"Re&quires\"" , gbox ); Q_CHECK_PTR( _searchInRequires ); - vlayout->addWidget(_searchInRequires); + vLayout->addWidget(_searchInRequires); - _searchInFileList = new QCheckBox( "File list" , gbox ); Q_CHECK_PTR( _searchInFileList ); - vlayout->addWidget(_searchInFileList); + _searchInFileList = new QCheckBox( _( "File list" ), gbox ); Q_CHECK_PTR( _searchInFileList ); + vLayout->addWidget(_searchInFileList); _searchInName->setChecked( true ); @@ -124,22 +125,22 @@ label = new QLabel( _( "Search &Mode:" ), this ); Q_CHECK_PTR( label ); - layout->addWidget(label); + layout->addWidget( label ); _searchMode = new QComboBox( this ); Q_CHECK_PTR( _searchMode ); - layout->addWidget(_searchMode); + layout->addWidget( _searchMode ); _searchMode->setEditable( false ); label->setBuddy( _searchMode ); // Caution: combo box items must be inserted in the same order as enum SearchMode! - _searchMode->addItem( _( "Contains" ) ); - _searchMode->addItem( _( "Begins with" ) ); - _searchMode->addItem( _( "Exact Match" ) ); - _searchMode->addItem( _( "Use Wild Cards" ) ); - _searchMode->addItem( _( "Use Regular Expression" ) ); + _searchMode->addItem( _( "Contains" ) ); + _searchMode->addItem( _( "Begins with" ) ); + _searchMode->addItem( _( "Exact Match" ) ); + _searchMode->addItem( _( "Use Wild Cards" ) ); + _searchMode->addItem( _( "Use Regular Expression" ) ); _searchMode->setCurrentIndex( Contains ); @@ -151,7 +152,7 @@ layout->addWidget(_caseSensitive); for ( int i=0; i < 6; i++ ) - layout->addStretch(); + layout->addStretch(); } @@ -210,113 +211,139 @@ emit filterStart(); _matchCount = 0; - if ( ! _searchText->currentText().isEmpty() ) + try { - // Create a progress dialog that is only displayed if the search takes - // longer than a couple of seconds ( default: 4 ). + if ( ! _searchText->currentText().isEmpty() ) + { + // Create a progress dialog that is only displayed if the search takes + // longer than a couple of seconds ( default: 4 ). - zypp::PoolQuery query; - query.addKind(zypp::ResKind::package); - - string searchtext = _searchText->currentText().toUtf8().data(); - - QProgressDialog progress( _( "Searching..." ), // text - _( "&Cancel" ), // cancelButtonLabel - 0, - 1000, - this // parent - ); - progress.setWindowTitle( "" ); - progress.setMinimumDuration( 1500 ); // millisec - // HACK, this should go to YQPackageSelector - parentWidget()->parentWidget()->setCursor(Qt::WaitCursor); - progress.setCursor(Qt::ArrowCursor); - - QTime timer; - query.setCaseSensitive( _caseSensitive->isChecked() ); - - switch ( _searchMode->currentIndex() ) - { - case Contains: - query.setMatchSubstring(); - break; - case BeginsWith: - query.setMatchRegex(); - searchtext = "^" + searchtext; - break; - case ExactMatch: - break; - case UseWildcards: - query.setMatchGlob(); - break; - case UseRegExp: - query.setMatchRegex(); - break; - // Intentionally omitting "default" branch - let gcc watch for unhandled enums - } - - query.addString(searchtext); - - if ( _searchInName->isChecked() ) - query.addAttribute( zypp::sat::SolvAttr::name ); - if ( _searchInDescription->isChecked() ) - query.addAttribute( zypp::sat::SolvAttr::description ); - if ( _searchInSummary->isChecked() ) - query.addAttribute( zypp::sat::SolvAttr::summary ); - if ( _searchInRequires->isChecked() ) - query.addAttribute( zypp::sat::SolvAttr("solvable:requires") ); - if ( _searchInProvides->isChecked() ) - query.addAttribute( zypp::sat::SolvAttr("solvable:provides") ); - if ( _searchInFileList->isChecked() ) - { - query.addAttribute( zypp::sat::SolvAttr::filelist ); - query.matchFiles(); - } - - // always look in keywords so FATE #120368 is implemented - // but make this configurable later - query.addAttribute( zypp::sat::SolvAttr::keywords ); - - _searchText->setEnabled(false); - _searchButton->setEnabled(false); - - timer.start(); - - int count = 0; - - for ( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin(); - it != query.selectableEnd() && ! progress.wasCanceled(); - ++it ) - { - ZyppSel selectable = *it; - ZyppPkg zyppPkg = tryCastToZyppPkg( selectable->theObj() ); + zypp::PoolQuery query; + query.addKind(zypp::ResKind::package); + + string searchtext = _searchText->currentText().toUtf8().data(); + + QProgressDialog progress( _( "Searching..." ), // text + _( "&Cancel" ), // cancelButtonLabel + 0, + 1000, + this // parent + ); + progress.setWindowTitle( "" ); + progress.setMinimumDuration( 1500 ); // millisec + + // HACK, this should go to YQPackageSelector + parentWidget()->parentWidget()->setCursor(Qt::WaitCursor); + progress.setCursor(Qt::ArrowCursor); - if ( zyppPkg ) - { - _matchCount++; - emit filterMatch( selectable, zyppPkg ); - } - - if ( progress.wasCanceled() ) - break; - - progress.setValue( count++ ); + QTime timer; + query.setCaseSensitive( _caseSensitive->isChecked() ); - if ( timer.elapsed() > 300 ) // milisec + switch ( _searchMode->currentIndex() ) { - // Process events only every 300 milliseconds - this is very - // expensive since both the progress dialog and the package - // list change all the time, thus display updates are necessary - // each time. + case Contains: + query.setMatchSubstring(); + break; + case BeginsWith: + query.setMatchRegex(); + searchtext = "^" + searchtext; + break; + case ExactMatch: + break; + case UseWildcards: + query.setMatchGlob(); + break; + case UseRegExp: + query.setMatchRegex(); + break; - qApp->processEvents(); - timer.restart(); + // Intentionally omitting "default" branch - let gcc watch for unhandled enums + } + + query.addString( searchtext ); + + if ( _searchInName->isChecked() ) query.addAttribute( zypp::sat::SolvAttr::name ); + if ( _searchInDescription->isChecked() ) query.addAttribute( zypp::sat::SolvAttr::description ); + if ( _searchInSummary->isChecked() ) query.addAttribute( zypp::sat::SolvAttr::summary ); + if ( _searchInRequires->isChecked() ) query.addAttribute( zypp::sat::SolvAttr("solvable:requires") ); + if ( _searchInProvides->isChecked() ) query.addAttribute( zypp::sat::SolvAttr("solvable:provides") ); + if ( _searchInFileList->isChecked() ) + { + query.addAttribute( zypp::sat::SolvAttr::filelist ); + query.matchFiles(); } + + // always look in keywords so FATE #120368 is implemented + // but make this configurable later + query.addAttribute( zypp::sat::SolvAttr::keywords ); + + _searchText->setEnabled(false); + _searchButton->setEnabled(false); + + timer.start(); + + int count = 0; + + for ( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin(); + it != query.selectableEnd() && ! progress.wasCanceled(); + ++it ) + { + ZyppSel selectable = *it; + ZyppPkg zyppPkg = tryCastToZyppPkg( selectable->theObj() ); + + if ( zyppPkg ) + { + _matchCount++; + emit filterMatch( selectable, zyppPkg ); + } + + if ( progress.wasCanceled() ) + break; + + progress.setValue( count++ ); + + if ( timer.elapsed() > 300 ) // milisec + { + // Process events only every 300 milliseconds - this is very + // expensive since both the progress dialog and the package + // list change all the time, thus display updates are necessary + // each time. + + qApp->processEvents(); + timer.restart(); + } + } + + if ( _matchCount == 0 ) + emit message( _( "No Results." ) ); } + } + catch ( const std::exception & exception ) + { + yuiWarning() << "CAUGHT zypp exception: " << exception.what() << endl; + + QMessageBox msgBox; + + // Translators: This is a (short) text indicating that something went + // wrong while searching for packages. At this point, it is not clear + // if it's a user error (e.g., syntax error in regular expression) or + // an internal error. But there is a "Details" button that will return + // the original (translated) error message. - if ( _matchCount == 0 ) - emit message( _( "No Results." ) ); + QString heading = _( "Query Error" ); + + if ( heading.length() < 25 ) // Avoid very narrow message boxes + { + QString blanks; + blanks.fill( ' ', 50 - heading.length() ); + heading += blanks; + } + + msgBox.setText( heading ); + msgBox.setIcon( QMessageBox::Warning ); + msgBox.setInformativeText( fromUTF8( exception.what() ) ); + msgBox.exec(); } _searchText->setEnabled(true); @@ -326,6 +353,7 @@ emit filterFinished(); } + bool YQPkgSearchFilterView::check( ZyppSel selectable, ZyppObj zyppObj ) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org