Bugzilla – Bug 119090
Qt/KDE Integration Bug
Last modified: 2007-07-12 10:17:01 UTC
There is a bug in the Qt/KDE integration patches to Qt in SuSE 9.3/10.x which is causing third-party applications such as Quasar, Scribus, and LinCVS to fail to work properly. Its easy to duplicate and show and is a problem in the patch to redirect Qt QMessageBox static methods to KDE message boxes. The basic problem is that there are two ways to call the QMessageBox functions. One way you pass in the text for the buttons on the message box and it should return which button was pressed (0, 1, or 2). The other way to call something like QMessageBox::warning though is to pass in a list of button ids such as QMessageBox::Yes/No/Cancel/... and in this case what should be returned is the button id that was clicked. The replacement code added in SuSE 9.3 that passes these functions off to KDE treats these both the same and will return the button number (0/1/2) in each case. So any code that uses Qt and calls QMessageBox::warning with button ids of QMessageBox::Yes and QMessageBox::No and then checks the result to make sure it matches QMessageBox::Yes will now fail and the user is left with an application that won't do the work regardless of whether they choose Yes or No! SuSE 9.2 works, but the bug causes the buttons to be switched. No on the left and Yes on the right. Normal placement should be Yes=left & No=right. This was reported to SuSE support and then to the Technical Feedback and have not yet seen a fix or any acknowledgment of the problem so I thought I would have one last kick at trying to get through to someone at SuSE to get this fixed. The only other alternative for applications effected is to static compile the application with our own copy of Qt which doesn't have the KDE integration patches but this is a pain and means the application doesn't have the native look and feel.
Created attachment 51000 [details] Example showing problem Compile the dialog_test.cpp code and run the problem and click on the buttons and it will return 0 or 1. Set QT_NO_KDE_INTEGRATION=1 and export QT_NO_KDE_INTEGRATION and then run the test program again and it will return 3 or 4 as it should showing that when the KDE integration is turned on, the wrong results are returned from the function.
I've been told that someone at SuSE says this is actually not a bug in the SuSE code but rather coding errors in the programs using Qt and this is simply not true and is an insult to someone who has spent a fair chunk of time to try and track this down only to be told its his own mistake. As the example program I just posted shows, a very simple program will return different results depending on whether it is run with or without the Qt/KDE integration turned on. With it off its calling the Qt functions so I would have to say the results from that are the correct ones but with it on and with the SuSE written KDE functions being used instead of the Qt ones, different results are returned which *IS* a SuSE bug! This bug was introduced in SuSE 9.3 and is still around in the 10.0 code and needs to be fixed!
Fixed in kdebase-SuSE (trunk). No idea what to do with this now WRT 9.3/10.0.
Created attachment 51593 [details] kdebase-SuSE patch And here's the patch separately if needed.
Ok, it's also in 9.3/10.0 branches in SVN.
Can you advise which versioned packages will have these fixes ?
<coolo> Seli: NEEDINFO aj@suse.de with the info that this breaks 3rd party app, if he gives a swampid, reassign to lukas
*** Bug 138013 has been marked as a duplicate of this bug. ***
Go ahead, swamp-ID is: Maintenance-Tracker-3201
I am hitting this bug when running the Quasar Accounting application. This Qt based application behaves as expected until the user submits a Yes/No response. I am able to workaround this bug by setting QT_NO_KDE_INTEGRATION=1. I see this behaviour on two SuSE 10.0 fully updated systems.
Done, backported to 9.3 and 10.0
patchinfo missing
DISTRIBUTION: 10.0-i586,9.3-i586 PACKAGE: kdebase3-SuSE PACKAGER: ltinkl@suse.cz PATCHFILENAME: CATEGORY: optional SUMMARY: Qt/KDE Integration Bug INDICATIONS: Swapped buttons in QMessageBox dialogs DESCRIPTION: This update fixes problems with buttons being swapped in QMessageBoxes when the Qt/KDE integration is enabled.
DISTRIBUTION: 9.3-i386,9.3-x86_64,10.0-i386,10.0-ppc,10.0-x86_64 PACKAGE: kdebase3-SuSE PACKAGER: ltinkl@suse.cz CATEGORY: optional SWAMPID: 3201 SUMMARY: Qt/KDE Integration Bug INDICATIONS: Swapped buttons in QMessageBox dialogs DESCRIPTION: This update fixes problems with buttons being swapped in QMessageBoxes when the Qt/KDE integration is enabled. DESCRIPTION_DE: Dieses Update behebt Probleme mit vertauschten Knöpfen in QMessageBoxes bei aktivierter Qt/KDE Integration. packages checked in, patchinfo submitted
Lukas, next time please also include the affected BUGZILLA ids released
Sorry, but this bug is not really fixed. Try this: --- switch( QMessageBox::warning( this, "Caption", "Text", QMessageBox::Ok | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape)) { case QMessageBox::Ok: qDebug("OK"); break; case QMessageBox::Cancel: qDebug("Cancel"); break; default: qDebug("Nothing"); }
Fix for wrong button texts: --- ./qtkdeintegration/module/module.cpp 2006-06-14 15:36:37.000000000 +0200 +++ ../kdebase-SuSE-orig/qtkdeintegration/module/module.cpp 2006-06-14 15:38:33.000000000 +0200 @@ -155,7 +155,7 @@ for( int i = 0; i < 3; ++i ) - switch( buttons[ i ] ) + switch( buttons[ i ] & QMessageBox::ButtonMask ) { case QMessageBox::Ok: buttonItems[ i ] = KStdGuiItem::ok();
lovely, thanks. adrian/AJ: YOU for this?
yes, compatibility is holy ...
fine, but please wait a minute. let me first fix it completely. ;)
ok, waiting
OK. Forget the last patch and apply this one. Now it also returns the correct result. i.e. bottoncode not or'ed with something. --- ../kdebase-SuSE-suse/qtkdeintegration/module/module.cpp 2006-06-14 15:36:37.000000000 +0200 +++ ./qtkdeintegration/module/module.cpp 2006-06-14 17:16:06.000000000 +0200 @@ -150,7 +150,12 @@ { static const char* const caps[ 4 ] = { I18N_NOOP( "Information" ), I18N_NOOP( "Question" ), I18N_NOOP( "Warning" ), I18N_NOOP( "Error" )}; - int buttons[ 3 ] = { button0, button1, button2 }; + int buttons[ 3 ] = + { + button0&QMessageBox::ButtonMask, + button1&QMessageBox::ButtonMask, + button2&QMessageBox::ButtonMask + }; KGuiItem buttonItems[ 3 ]; for( int i = 0; i < 3; @@ -208,8 +213,8 @@ KDialogBase *dialog= new KDialogBase( caption.isEmpty() ? i18n( caps[ type ] ) : caption, KDialogBase::Yes - | ( button1 == QMessageBox::NoButton ? 0 : int( KDialogBase::No )) - | ( button2 == QMessageBox::NoButton ? 0 : int( KDialogBase::Cancel )), + | ( buttons[1] == QMessageBox::NoButton ? 0 : int( KDialogBase::No )) + | ( buttons[2] == QMessageBox::NoButton ? 0 : int( KDialogBase::Cancel )), defaultButton, escapeButton, NULL, "messageBox2", true, true, buttonItems[ 0 ], buttonItems[ 1 ],buttonItems[ 2 ] );
btw: is it possible to include also the fix for #181275 in the online-update? ;)
adrian, could you please have a look?
Not sure if this should be a new bug or not but another problem with this code (and the code that redirects the printer dialog to the KDE one) is that it doesn't show up centered over the parent window like it should and focus doesn't always return to the right window when the dialog exits. For example if I have top level window and its not in the middle of the screen and I use the real Qt QMessageBox warning() method then it shows up in the middle of the correct window. If I'm using the SuSE redirection to KDE then the dialog is centered on the whole screen and not on the window active when the call was made. And if I use the printer dialog from a window other than the application main window (so from another top level window that open), then the print dialog appears in the middle of the screen and when its closed the focus goes back to the main window of the application and not the window the focus was in before. These are annoying user interface bugs that should be fixed in this whole KDE integration thing!
Following patch additionally centers the MessageBoxes. diff -ur ../kdebase-SuSE-suse/qtkdeintegration/module/module.cpp ./qtkdeintegration/module/module.cpp --- ../kdebase-SuSE-suse/qtkdeintegration/module/module.cpp 2006-06-14 15:36:37.000000000 +0200 +++ ./qtkdeintegration/module/module.cpp 2006-06-19 13:54:09.000000000 +0200 @@ -34,6 +34,9 @@ XSetClassHint( qt_xdisplay(), w->winId(), &hints ); KWin::setMainWindow( w, parent ); KWin::setState( w->winId(), NET::Modal ); + QRect parentRect(KWin::windowInfo(parent).geometry()); + w->move( parentRect.x() + (parentRect.width() - w->width())/2, + parentRect.y() + (parentRect.height()- w->height())/2); } // duped in qtkde @@ -150,7 +153,12 @@ { static const char* const caps[ 4 ] = { I18N_NOOP( "Information" ), I18N_NOOP( "Question" ), I18N_NOOP( "Warning" ), I18N_NOOP( "Error" )}; - int buttons[ 3 ] = { button0, button1, button2 }; + int buttons[ 3 ] = + { + button0&QMessageBox::ButtonMask, + button1&QMessageBox::ButtonMask, + button2&QMessageBox::ButtonMask + }; KGuiItem buttonItems[ 3 ]; for( int i = 0; i < 3; @@ -208,8 +216,8 @@ KDialogBase *dialog= new KDialogBase( caption.isEmpty() ? i18n( caps[ type ] ) : caption, KDialogBase::Yes - | ( button1 == QMessageBox::NoButton ? 0 : int( KDialogBase::No )) - | ( button2 == QMessageBox::NoButton ? 0 : int( KDialogBase::Cancel )), + | ( buttons[1] == QMessageBox::NoButton ? 0 : int( KDialogBase::No )) + | ( buttons[2] == QMessageBox::NoButton ? 0 : int( KDialogBase::Cancel )), defaultButton, escapeButton, NULL, "messageBox2", true, true, buttonItems[ 0 ], buttonItems[ 1 ],buttonItems[ 2 ] );
Yes, this is important for us and please also include the fix from #181275
SWAMPID is 4795 for both bugfixes. Please submit patch and patchinfo file. thx
Lubos, can you review and submit the changes to SVN? I'll add it to the package then.
Fixed in trunk, SUSE_10_1_BRANCH and Code10-Desktop, I hope I didn't forget something. Comment #25: We don't change anything about the print dialog.
ok, submitted. Please note that we can't push it out until SLE is done.