From 419e0bfd2fcf9b81799000ada5d48b1c33375c92 Mon Sep 17 00:00:00 2001 From: coolo Date: Tue, 11 Dec 2007 18:13:07 +0000 Subject: [PATCH] several bug fixes to speed up the startup git-svn-id: http://svn.opensuse.org/svn/yast/trunk/qt4@42985 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/QY2Styler.cc | 4 +++- src/YQUI.h | 5 +++++ src/YQUI_core.cc | 36 +++++++++++++++++++++++------------- src/pkg/YQPkgObjList.cc | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/QY2Styler.cc b/src/QY2Styler.cc index fd126e8..ba01fef 100644 --- a/src/QY2Styler.cc +++ b/src/QY2Styler.cc @@ -77,7 +77,9 @@ bool QY2Styler::eventFilter( QObject * obj, QEvent * ev ) } QPixmap result( wid->size() ); - result.fill( QColor( 0, 0, 0, 0 ) ); + if ( wid->contentsRect() != wid->rect() ) + result.fill( QColor( 0, 128, 0, 0 ) ); + QPainter pain( &result ); pain.drawImage( wid->contentsRect().topLeft(), _backgroundPx[name].scaled( wid->contentsRect().width(), wid->contentsRect().height() ) ); diff --git a/src/YQUI.h b/src/YQUI.h index 1fb69ab..a7b6ce7 100644 --- a/src/YQUI.h +++ b/src/YQUI.h @@ -413,6 +413,8 @@ protected: **/ void userInputTimeout(); + void leaveIdleLoop(); + // // Data members // @@ -446,6 +448,8 @@ protected: **/ bool _do_exit_loop; + bool _leave_idle_loop; + /** * Event loop object. Required since a YaST2 UI needs to react to commands * from the YCP command stream as well as to X11 / Qt events. @@ -532,6 +536,7 @@ public slots: **/ void slotUserInputTimeout(); + void slotLeaveIdleLoop(); }; #endif // YQUI_h diff --git a/src/YQUI_core.cc b/src/YQUI_core.cc index 9269e19..2eaec47 100644 --- a/src/YQUI_core.cc +++ b/src/YQUI_core.cc @@ -381,21 +381,29 @@ void YQUI::idleLoop( int fd_ycp ) { init_ui(); - // runs in main thread - _eventLoop->wakeUp(); + _leave_idle_loop = false; - fd_set rfds; + // process Qt events until fd_ycp is readable. + QSocketNotifier * notifier = new QSocketNotifier( fd_ycp, QSocketNotifier::Read ); + QObject::connect( notifier, SIGNAL( activated ( int ) ), + _qobject, SLOT( slotLeaveIdleLoop() ) ); - FD_ZERO(&rfds); - FD_SET(fd_ycp, &rfds); + notifier->setEnabled( true ); - while (true) - { - int retval = select(fd_ycp+1, &rfds, NULL, NULL, NULL); - if (retval) - break; - } - _eventLoop->exit(); + while ( !_leave_idle_loop ) + _eventLoop->processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents ); + + delete notifier; +} + +void YQUI::leaveIdleLoop() +{ + _leave_idle_loop = true; +} + +void YQUI_Ui::slotLeaveIdleLoop() +{ + YQUI::ui()->leaveIdleLoop(); } void YQUI::sendEvent( YEvent * event ) @@ -418,7 +426,7 @@ YEvent * YQUI::userInput( unsigned long timeout_millisec ) _eventLoop->wakeUp(); blocked_level = 0; - //y2milestone( "userInput %ld", timeout_millisec ); + //y2milestone( "userInput %ld %ld", timeout_millisec, QThread::currentThreadId() ); YEvent * event = 0; YQDialog * dialog = dynamic_cast ( YDialog::currentDialog( false ) ); @@ -534,6 +542,8 @@ YQUI::setTextdomain( const char * domain ) void YQUI::blockEvents( bool block ) { + init_ui(); + if ( block ) { if ( ++blocked_level == 1 ) diff --git a/src/pkg/YQPkgObjList.cc b/src/pkg/YQPkgObjList.cc index 44b73f6..b2ee8c4 100644 --- a/src/pkg/YQPkgObjList.cc +++ b/src/pkg/YQPkgObjList.cc @@ -359,7 +359,7 @@ YQPkgObjList::selectNextItem() QTreeWidgetItemIterator it(this); QTreeWidgetItem * item; - while ( item = *it) + while ( (item = *it) != NULL ) { ++it; //item->setSelected( false ); // Doesn't emit signals -- 2.39.2