Fwd: [Kde-java] Problem with polish method

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Sep 30 14:15:18 CEST 2004


On Thursday 30 September 2004 12:16, David Goodenough wrote:
> The polish method that juic emits reads:-
>
>     /**
>      * polish does some last initialization just before the widget
>      * is displayed. Here we setup:
>      *   i) databases
>      *   ...
>      */
>     public void polish() {
>        
>         if ( customers != null ) {
>             QSqlCursor cursor = customers.sqlCursor();
>             if ( cursor == null ) {
>                 cursor = new QSqlCursor( "customers"  );
>                 customers.setSqlCursor( cursor, false, true );
>             }
>             if ( !cursor.isActive() )
>                 customers.refresh( QDataTable.RefreshAll );
>         }
>        
>         super.polish();
>     }
>    
> Unfortunately this leads to an infinite recursion, as
> super.polish( ) just seems to reinvoke this polish routine.
> The class that this is part of extends QMainWindow.

On Thursday 30 September 2004 12:16, David Goodenough wrote:
> Richard,
>
> I do not know if you spotted this one on the kde-java list, but it has
> me stumped.  Any ideas?
>
> Thanks in advance,
Hi David

I've looked at the code, and it does look like it will loop. You can call 
super from an event handler without looping, because it's protected. Instead 
of (1) calling (2) which calls (1) again and so on forever. In an event 
handler (3) calls (4), which then calls (5) and there isn't a loop.

I've got a bit obsessed with ruby recently, and have totally neglected doing 
any work on the java bindings. All I do is keep apologising on the kde-java 
list every few weeks for not having done anything.

The next release of KDE is being tagged on Saturday, so maybe I'll be able to 
do something by then. I don't think super.polish() actually does anything by 
default, so you can just leave it out without doing any harm.

-- Richard

Public virtual method
------------------------------
(I)
 void polish() {
  if (!QtSupport::voidDelegate(this,"polish")) {
   QWidget::polish();
  }
  return;
 }

(2)
JNIEXPORT void JNICALL
Java_org_kde_qt_QWidget_polish(JNIEnv* env, jobject obj)
{
 ((QWidget*) QtSupport::getQt(env, obj))->polish();
 return;
}

Protected virtual method
-----------------------------------
(3)
 void mouseMoveEvent(QMouseEvent* arg1) {
  if (!QtSupport::eventDelegate(this,"mouseMoveEvent",
(void*)arg1,"org.kde.qt.QMouseEvent")) {
   QWidget::mouseMoveEvent(arg1);
  }
  return;
 }

(4)
JNIEXPORT void JNICALL
Java_org_kde_qt_QWidget_mouseMoveEvent(JNIEnv* env, jobject obj, jobject arg1)
{
 ((QWidgetJBridge*) QtSupport::getQt(env, 
obj))->protected_mouseMoveEvent((QMouseEvent*) QtSupport::getQt(env, arg1));
 return;
}

(5)
 void protected_mouseMoveEvent(QMouseEvent* arg1) {
  QWidget::mouseMoveEvent(arg1);
  return;
 }


More information about the Kde-java mailing list