Author: coolo
Date: Tue Dec 11 09:59:20 2007
New Revision: 42934
URL: http://svn.opensuse.org/viewcvs/yast?rev=42934&view=rev
Log:
don't create QObjects in ycp thread - make timeouts work
Modified:
trunk/qt4/src/YQUI.h
trunk/qt4/src/YQUI_builtins.cc
trunk/qt4/src/YQUI_core.cc
trunk/qt4/src/YQUI_x11.cc
Modified: trunk/qt4/src/YQUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQUI.h?rev=42934&r1=42933&r2=42934&view=diff
==============================================================================
--- trunk/qt4/src/YQUI.h (original)
+++ trunk/qt4/src/YQUI.h Tue Dec 11 09:59:20 2007
@@ -42,14 +42,16 @@
class YQPackageSelectorPlugin;
class YQWidgetFactory;
class YQApplication;
+class YQUI_Ui;
using std::string;
using std::vector;
-class YQUI: public QObject, public YUI
+class YQUI: public YUI
{
- Q_OBJECT
+ friend class YQUI_Ui;
+
public:
/**
@@ -224,16 +226,6 @@
**/
void beep();
-
-public slots:
-
- /**
- * Show hourglass cursor.
- *
- * Reimplemented from YUI.
- **/
- void busyCursor();
-
/**
* Show pointer cursor.
*
@@ -364,6 +356,12 @@
**/
YQPackageSelectorPlugin * packageSelectorPlugin();
+ /**
+ * Show hourglass cursor.
+ *
+ * Reimplemented from YUI.
+ **/
+ virtual void busyCursor();
protected:
@@ -391,18 +389,11 @@
QMap screenShotNo;
QString screenShotNameTemplate;
-protected slots:
-
/**
* Application shutdown
**/
bool close();
- /**
- * Timeout during TimeoutUserInput() / WaitForEvent()
- **/
- void userInputTimeout();
-
protected:
/**
@@ -415,7 +406,12 @@
**/
void calcDefaultSize();
- void init_ui();
+ void init_ui();
+
+ /**
+ * Timeout during TimeoutUserInput() / WaitForEvent()
+ **/
+ void userInputTimeout();
//
// Data members
@@ -511,6 +507,31 @@
* Reads the style sheet, parses some comments and passes it to qapp
*/
QY2Styler *_styler;
+
+ YQUI_Ui *_qobject;
+};
+
+class YQUI_Ui : public QObject
+{
+ Q_OBJECT
+
+public:
+ YQUI_Ui();
+
+public slots:
+
+ /**
+ * Show hourglass cursor.
+ *
+ * Reimplemented from YUI.
+ **/
+ void slotBusyCursor();
+
+ /**
+ * Timeout during TimeoutUserInput() / WaitForEvent()
+ **/
+ void slotUserInputTimeout();
+
};
#endif // YQUI_h
Modified: trunk/qt4/src/YQUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQUI_builtins.cc?rev=42934&r1=42933&r2=42934&view=diff
==============================================================================
--- trunk/qt4/src/YQUI_builtins.cc (original)
+++ trunk/qt4/src/YQUI_builtins.cc Tue Dec 11 09:59:20 2007
@@ -280,9 +280,9 @@
<< "Debug logging on";
QString result = QInputDialog::getItem( _main_win,
- tr("YaST2 Logging"),
- tr("Configure YaST2 Logging:"),
- items, 0, get_log_debug() ? 1 : 0, &okButtonPressed);
+ _("YaST2 Logging"),
+ _("Configure YaST2 Logging:"),
+ items, 0, get_log_debug() ? 1 : 0, &okButtonPressed);
if ( okButtonPressed )
{
set_log_debug( result.endsWith( "on" ) );
Modified: trunk/qt4/src/YQUI_core.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQUI_core.cc?rev=42934&r1=42933&r2=42934&view=diff
==============================================================================
--- trunk/qt4/src/YQUI_core.cc (original)
+++ trunk/qt4/src/YQUI_core.cc Tue Dec 11 09:59:20 2007
@@ -43,7 +43,6 @@
#include "YQDialog.h"
#include "QY2Settings.h"
-#define NOWARNINGS 0
#define BUSY_CURSOR_TIMEOUT 200 // milliseconds
YQUI * YQUI::_ui = 0;
@@ -51,8 +50,7 @@
static void qMessageHandler( QtMsgType type, const char * msg );
YQUI::YQUI( int argc, char **argv, bool with_threads, const char * macro_file )
- : QObject()
- , YUI( with_threads )
+ : YUI( with_threads )
, _main_win( NULL )
, _do_exit_loop( false )
, _eventLoop( 0 )
@@ -85,27 +83,25 @@
topmostConstructorHasFinished();
}
+YQUI_Ui::YQUI_Ui()
+ : QObject()
+{
+}
+
void YQUI::init_ui()
{
if (_ui_inited)
return;
-#if NOWARNINGS
- /*
- Qt thinks the first QObject defines the main thread, but
- the main thread in this case is the ycp thread, not UI
- */
- extern void qt_set_current_thread_to_main_thread();
- qt_set_current_thread_to_main_thread();
-#endif
-
_ui_inited = true;
new QApplication( _ui_argc, _ui_argv);
- _busy_cursor_timer = new QTimer( qApp );
+
+ _qobject = new YQUI_Ui();
+ _busy_cursor_timer = new QTimer( _qobject );
_busy_cursor_timer->setSingleShot( true );
- _user_input_timer = new QTimer( qApp );
+ _user_input_timer = new QTimer( _qobject );
_user_input_timer->setSingleShot( true );
_normalPalette = qApp->palette();
@@ -199,11 +195,11 @@
qApp->setFont( yqApp()->currentFont() );
busyCursor();
- connect( _user_input_timer, SIGNAL( timeout() ),
- this, SLOT ( userInputTimeout() ) );
+ QObject::connect( _user_input_timer, SIGNAL( timeout() ),
+ _qobject, SLOT ( slotUserInputTimeout() ) );
- connect( _busy_cursor_timer, SIGNAL( timeout() ),
- this, SLOT ( busyCursor() ) );
+ QObject::connect( _busy_cursor_timer, SIGNAL( timeout() ),
+ _qobject, SLOT ( slotBusyCursor() ) );
#warning macro_file
// if ( macro_file )
@@ -427,8 +423,7 @@
YEvent * event = 0;
YQDialog * dialog = dynamic_cast ( YDialog::currentDialog( false ) );
- if ( _user_input_timer->isActive() )
- _user_input_timer->stop();
+ _user_input_timer->stop();
if ( dialog )
{
@@ -451,9 +446,9 @@
_busy_cursor_timer->start( BUSY_CURSOR_TIMEOUT ); // single shot
}
- if ( _user_input_timer->isActive() )
- _user_input_timer->stop();
+ _user_input_timer->stop();
+ qDebug( "return event %p", event );
return event;
}
@@ -462,8 +457,7 @@
{
YEvent * event = 0;
- if ( _user_input_timer->isActive() )
- _user_input_timer->stop();
+ _user_input_timer->stop();
if ( ! pendingEvent() )
{
@@ -483,6 +477,11 @@
}
+void YQUI_Ui::slotUserInputTimeout()
+{
+ YQUI::ui()->userInputTimeout();
+}
+
void YQUI::userInputTimeout()
{
if ( ! pendingEvent() )
@@ -570,9 +569,7 @@
break;
case QtWarningMsg:
y2warning ("qt-warning: %s\n", msg);
-#if NOWARNINGS
abort();
-#endif
break;
case QtCriticalMsg:
y2warning ("qt-critical: %s\n", msg);
Modified: trunk/qt4/src/YQUI_x11.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQUI_x11.cc?rev=42934&r1=42933&r2=42934&view=diff
==============================================================================
--- trunk/qt4/src/YQUI_x11.cc (original)
+++ trunk/qt4/src/YQUI_x11.cc Tue Dec 11 09:59:20 2007
@@ -91,6 +91,11 @@
qApp->beep();
}
+void
+YQUI_Ui::slotBusyCursor()
+{
+ YQUI::ui()->busyCursor();
+}
void
YQUI::busyCursor( void )
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org