Bug 119090 - Qt/KDE Integration Bug
Summary: Qt/KDE Integration Bug
Status: RESOLVED FIXED
: 138013 (view as bug list)
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: KDE (show other bugs)
Version: RC 1
Hardware: i686 SUSE Other
: P5 - None : Major
Target Milestone: ---
Assignee: E-mail List
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-27 19:37 UTC by Patrick Smith
Modified: 2007-07-12 10:17 UTC (History)
9 users (show)

See Also:
Found By: Beta-Customer
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Example showing problem (284 bytes, text/x-c++src)
2005-09-28 03:59 UTC, Forgotten User mf5XHPErBa
Details
kdebase-SuSE patch (1.72 KB, patch)
2005-10-06 13:05 UTC, Lubos Lunak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Smith 2005-09-27 19:37:41 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.
Comment 1 Forgotten User mf5XHPErBa 2005-09-28 03:59:15 UTC
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.
Comment 2 Forgotten User mf5XHPErBa 2005-09-28 04:05:24 UTC
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!
Comment 3 Lubos Lunak 2005-10-06 13:04:48 UTC
Fixed in kdebase-SuSE (trunk). No idea what to do with this now WRT 9.3/10.0. 
 
Comment 4 Lubos Lunak 2005-10-06 13:05:31 UTC
Created attachment 51593 [details]
kdebase-SuSE patch

And here's the patch separately if needed.
Comment 5 Lubos Lunak 2005-10-06 13:18:19 UTC
Ok, it's also in 9.3/10.0 branches in SVN. 
 
Comment 6 P Linnell 2005-10-21 22:47:58 UTC
Can you advise which versioned packages will have these fixes ? 
Comment 7 Lubos Lunak 2005-12-09 15:41:05 UTC
<coolo> Seli: NEEDINFO aj@suse.de with the info that this breaks 3rd party app, if he gives a swampid, reassign to lukas
Comment 8 Dirk Mueller 2005-12-12 10:21:01 UTC
*** Bug 138013 has been marked as a duplicate of this bug. ***
Comment 9 Andreas Jaeger 2005-12-12 12:14:53 UTC
Go ahead, swamp-ID is:   	 Maintenance-Tracker-3201
Comment 10 Robert March 2006-01-05 15:29:05 UTC
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.
Comment 11 Lukas Tinkl 2006-01-06 12:48:39 UTC
Done, backported to 9.3 and 10.0
Comment 12 Ruediger Oertel 2006-01-26 17:32:35 UTC
patchinfo missing
Comment 13 Lukas Tinkl 2006-01-31 13:26:57 UTC
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.
Comment 14 Ruediger Oertel 2006-01-31 23:13:12 UTC
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
Comment 15 Anja Stock 2006-02-01 10:01:49 UTC
Lukas, next time please also include the affected BUGZILLA ids

released
Comment 16 Martin Pley 2006-06-13 12:56:40 UTC
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");
    }
Comment 17 Martin Pley 2006-06-14 13:37:54 UTC
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();
Comment 18 Dirk Mueller 2006-06-14 14:10:40 UTC
lovely, thanks. 

adrian/AJ: YOU for this?
Comment 19 Adrian Schröter 2006-06-14 14:24:30 UTC
yes, compatibility is holy ...
Comment 20 Martin Pley 2006-06-14 14:47:21 UTC
fine, but please wait a minute. let me first fix it completely. ;)
Comment 21 Dirk Mueller 2006-06-14 15:08:56 UTC
ok, waiting
Comment 22 Martin Pley 2006-06-14 15:16:39 UTC
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 ] );
Comment 23 Martin Pley 2006-06-14 15:18:16 UTC
btw: is it possible to include also the fix for #181275 in the online-update? ;)
Comment 24 Anja Stock 2006-06-16 09:13:24 UTC
adrian, could you please have a look?
Comment 25 Forgotten User mf5XHPErBa 2006-06-18 23:44:13 UTC
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!
Comment 26 Martin Pley 2006-06-19 11:53:39 UTC
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 ] );
Comment 27 Adrian Schröter 2006-06-19 14:21:50 UTC
Yes, this is important for us and please also include the fix from #181275
Comment 28 Anja Stock 2006-06-19 14:31:24 UTC
SWAMPID is 4795 for both bugfixes. Please submit patch and patchinfo file. thx 
Comment 29 Dirk Mueller 2006-06-22 20:41:07 UTC
Lubos, can you review and submit the changes to SVN? I'll add it to the package then. 
Comment 30 Lubos Lunak 2006-06-23 09:41:36 UTC
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.
Comment 31 Dirk Mueller 2006-06-23 12:48:43 UTC
ok, submitted. Please note that we can't push it out until SLE is done.