Version: (using KDE KDE 3.4.0) Installed from: SuSE RPMs OS: Linux The following program defines a widget TestWidget which inherits from QWidget and overloads the event handler mouseReleaseEvent(). It also defines a widget TestWidget2 which inherits from TestWidget and overloads mousePressEvent(). Both widgets should handle the mouseReleaseEvent() but only TestWidget does. If you add a mouseReleaseEvent() to class TestWidget2 which calls the super-method than it works as expected. The calling of Java methods from the C++ wrapper code seems to be broken. import org.kde.qt.QApplication; import org.kde.qt.QCloseEvent; import org.kde.qt.QMouseEvent; import org.kde.qt.QWidget; import org.kde.qt.qtjava; /* * Created on 11.09.2005 * */ public class QtTest { QApplication app; class TestWidget extends QWidget { public TestWidget() { super(); resize(100,100); show(); } protected void mouseReleaseEvent(QMouseEvent arg0) { System.out.println("release"); super.mouseReleaseEvent(arg0); } } class TestWidget2 extends TestWidget { protected void closeEvent(QCloseEvent arg0) { System.out.println("quit"); app.quit(); super.closeEvent(arg0); } protected void mousePressEvent(QMouseEvent arg0) { System.out.println("press"); super.mousePressEvent(arg0); } } public QtTest(String[] args) { app = new QApplication(args); TestWidget w = new TestWidget(); TestWidget w2 = new TestWidget2(); app.exec(); } public static void main(String[] args) { qtjava.initialize(); new QtTest(args); } }
SVN commit 467774 by rdale: * This check via reflection to tell if an event method had been overriden was insufficiently herioc - I just love those java apis ;). This should fix the bug reported by Jochen Becher CCBUGS: 112409 CCMAIL: kde-java@kde.org M +8 -4 Invocation.java --- branches/KDE/3.5/kdebindings/qtjava/javalib/org/kde/qt/Invocation.java #467773:467774 @@ -442,11 +442,15 @@ Object onThis = qtjava.objectForQtKey(target, "org.kde.qt.QObject", false); try { - // Assume that an event handler is a protected method, so use getDeclaredMethod() - method = onThis.getClass().getDeclaredMethod(methodName, parameterType); + method = onThis.getClass().getMethod(methodName, parameterType); method.setAccessible(true); - } catch (NoSuchMethodException e) { - return false; + } catch (NoSuchMethodException e1) { + try { + method = onThis.getClass().getDeclaredMethod(methodName, parameterType); + method.setAccessible(true); + } catch (NoSuchMethodException e2) { + return true; + } } // Ignore any native code event handling methods
SVN commit 467777 by rdale: * Oops, the last commit solved the wrong problem. Instead of two nested exception handlers, which would get both protected and public methods, but not inherited ones. A loop is needed to look for inherited event methods, going up the class heirarchy. CCBUGS: 112409 CCMAIL: kde-java@kde.org M +8 -7 Invocation.java --- branches/KDE/3.5/kdebindings/qtjava/javalib/org/kde/qt/Invocation.java #467776:467777 @@ -440,18 +440,19 @@ Class[] parameterType = new Class[1]; parameterType[0] = Class.forName(qtjava.toFullyQualifiedClassName(argClass)); Object onThis = qtjava.objectForQtKey(target, "org.kde.qt.QObject", false); + + Class targetClass = onThis.getClass(); - try { - method = onThis.getClass().getMethod(methodName, parameterType); - method.setAccessible(true); - } catch (NoSuchMethodException e1) { + do { try { - method = onThis.getClass().getDeclaredMethod(methodName, parameterType); + method = targetClass.getDeclaredMethod(methodName, parameterType); method.setAccessible(true); - } catch (NoSuchMethodException e2) { + } catch (NoSuchMethodException e1) { return true; } - } + + targetClass = targetClass.getSuperclass(); + } while (targetClass != null); // Ignore any native code event handling methods if ((method.getModifiers() & Modifier.NATIVE) != 0) {
SVN commit 467780 by rdale: * Oops, wrong again. The event invoker should return false if it fails, not true CCBUGS: 112409 M +1 -1 Invocation.java --- branches/KDE/3.5/kdebindings/qtjava/javalib/org/kde/qt/Invocation.java #467779:467780 @@ -448,7 +448,7 @@ method = targetClass.getDeclaredMethod(methodName, parameterType); method.setAccessible(true); } catch (NoSuchMethodException e1) { - return true; + return false; } targetClass = targetClass.getSuperclass();
SVN commit 468238 by rdale: * Still trying to fix bug #112409 - fourth attempt, feeling lucky CCBUGS: 112409 CCMAIL: kde-java@kde.org M +6 -2 Invocation.java --- branches/KDE/3.5/kdebindings/qtjava/javalib/org/kde/qt/Invocation.java #468237:468238 @@ -436,7 +436,7 @@ if the method was successfully invoked, otherwise false. Used for event handling callbacks */ public static boolean invoke(long target, long arg, String argClass, String methodName) throws NoSuchMethodException, ClassNotFoundException { - Method method; + Method method = null; Class[] parameterType = new Class[1]; parameterType[0] = Class.forName(qtjava.toFullyQualifiedClassName(argClass)); Object onThis = qtjava.objectForQtKey(target, "org.kde.qt.QObject", false); @@ -447,13 +447,17 @@ try { method = targetClass.getDeclaredMethod(methodName, parameterType); method.setAccessible(true); + break; } catch (NoSuchMethodException e1) { - return false; } targetClass = targetClass.getSuperclass(); } while (targetClass != null); + if (targetClass == null) { + return false; + } + // Ignore any native code event handling methods if ((method.getModifiers() & Modifier.NATIVE) != 0) { return false;
Dear Bug Submitter, This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond. Thank you for helping us make KDE software even better for everyone!
Dear Bug Submitter, This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? Thank you for helping us make KDE software even better for everyone!
Thank you for reporting this issue in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version? If you can reproduce the issue, please change the status to "REPORTED" when replying. Thank you!
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone!