[Kde-java] Bug in KFileDialog

Felix Rodriguez kde-java@kde.org
Tue, 25 Feb 2003 13:17:21 -0500


Richard,

    Thanks for the solution. I'll test it out on my system and see how it 
goes. I am planning on releasing my program to the general public so I am 
wondering whether your patch will make it to the next version of kdelibs. 
Have you contacted the KDE maintainers about this problem?




At 05:27 PM 2/25/2003 +0000, you wrote:
>I've written a sed script to convert as many dynamic_casts in kdelibs as
>possible to qt_cast()'s by doing this sort of thing:
>
>cd kdelibs/kdeui
>FILES="ktoolbarhandler.cpp ktoolbar.cpp kcursor.cpp kaction.cpp kcombobox.cpp"
>rm -f tmp
>mkdir tmp save
>for FILE in  $FILES ; do
>cp $FILES save
>cat $FILE | sed -e 's/dynamic_cast<\([^\* ]*\) *\*>(\(.*()\) *)/(\2 == 0 ? 
>0 :
>(\1 *) (\2)->qt_cast("\1"))/' \
>  -e 's/dynamic_cast<\([^\* ]*\) *\*>(\(.*\) *)/(\2 == 0 ? 0 : (\1 *)
>(\2)->qt_cast("\1"))/' > tmp/$FILE
>  done
>  cp tmp/*.cpp .
>
>But to save doing all that, please find attached a patch for the KDE 3.1
>kdelibs. Copy the patch to the directory above kdelibs, then
>
>$ cd kdelibs
>$ patch -p1 < ../kdelibs_3_1_dyn_to_qt_cast.patch
>$ make
>$ su -c'make install'
>
>Not all dynamic_casts could be converted because the target wasn't an 
>instance
>of a QObject. However, after the patch the java KFileDialog.getOpenFileName()
>method should work correctly..
>
>-- Richard
>
>On Tuesday 25 February 2003 11:36 am, Richard Dale wrote:
> > On Sunday 23 February 2003 11:31 pm, Felix Rodriguez wrote:
> > >   I think I might have discovered a bug in the KFileDialog
> > > getOpenFileName method. I am using QFileDialog instead and this seems to
> > > be working fine. KFileDialog is supposed to be a dropin replacement for
> > > QFileDialog.
> >
> > The problem is that dynamic casts don't appear to work properly when
> > kdelibs is linked with a java app. I changed four dynamic casts in the
> > dialog code to use qt_cast() instead and that worked (eg one in
> > KComboBox::setLineEdit() caused the crash below).
> >
> > But when the code got as far as displaying the dialog, it crashed in the
> > QDialog::exec() call to handle the modal dialog. I would expect QFileDialog
> > to also use the exec() method, so I've no idea why that works fine.
> >
> > I'm using gcc 2.95 and glibc 2.2.5, I don't know if a newer compiler and
> > associated libs would work ok - which version are you using? Perhaps if the
> > app was compiled with gcj, rather than run under a jvm, it might work
> > properly.
> >
> > However, I couldn't switch from gcc 2.95 to gcc 3.2.2 to use gcj because
> > dynamic casts appeared to be crashing when I built KDE with it, and KDE
> > wouldn't start properly - and that was nothing to do with java. So I'm
> > feeling a bit stuck at the moment..
> >
> > -- Richard
> >
> > >  Here is the backtrace that is generated from gdb.
> > >
> > > #0  0x40511829 in wait4 () from /lib/libc.so.6
> > > #1  0x4058da24 in __DTOR_END__ () from /lib/libc.so.6
> > > #2  0x400308e3 in waitpid () from /lib/libpthread.so.0
> > > #3  0x4c93401e in KCrash::defaultCrashHandler(int) ()
> > >    from /usr/kde/3.1/lib/libkdecore.so.4
> > > #4  <signal handler called>
> > > #5  0x0820e610 in ?? ()
> > > #6  0x4c77e52b in KComboBox::setLineEdit(QLineEdit*) ()
> > >    from /usr/kde/3.1/lib/libkdeui.so.4
> > > #7  0x4c77d93d in KComboBox::KComboBox(bool, QWidget*, char const*) ()
> > >    from /usr/kde/3.1/lib/libkdeui.so.4
> > > #8  0x4c50c91b in KURLComboBox::KURLComboBox(KURLComboBox::Mode, bool,
> > > QWidget*, char const*) () from /usr/kde/3.1/lib/libkio.so.4
> > > #9  0x4c4ed880 in KFileDialog::init(QString const&, QString const&,
> > > QWidget*) () from /usr/kde/3.1/lib/libkio.so.4
> > > #10 0x4c4f1dd0 in KFileDialog::getOpenFileName(QString const&, QString
> > > const&, QWidget*, QString const&) () from /usr/kde/3.1/lib/libkio.so.4
> > > #11 0x4be1b3c0 in
> > > Java_org_kde_koala_KFileDialog_getOpenFileName__Ljava_lang_String_2Ljava_
> > >la ng_String_2Lorg_kde_qt_QWidget_2Ljava_lang_String_2 ()
> > >    from /usr/kde/3.1/lib/libkdejava.so.1.0.0
> > > #12 0x0806254d in ?? ()
> > > #13 0x0805fb29 in ?? ()
> > > #14 0x4045a9de in StubRoutines::_code1 ()
> > >
> > > _______________________________________________
> > > Kde-java mailing list
> > > Kde-java@mail.kde.org
> > > http://mail.kde.org/mailman/listinfo/kde-java
> >
> > _______________________________________________
> > Kde-java mailing list
> > Kde-java@mail.kde.org
> > http://mail.kde.org/mailman/listinfo/kde-java


Felix Rodriguez
Programmer Analyst
Phone: 860-685-3984
Email: frodriguez@mail.wesleyan.edu