[Kde-java] Bug in KFileDialog

Felix Rodriguez kde-java@kde.org
Wed, 26 Feb 2003 18:42:22 -0500


The gcj sounds like the easier option for me. I'll try compiling my program 
under gcj to see if I still get the crash.

To get the C++ stack trace I did the following.

Dr Konqui always hangs but never gets the backtrace so I did a ps -A and I 
found the last java process id. Then I ran gdb and attached to the process id 
I got from ps. This generates a lot of verbage that you have to keep hitting 
enter through. Finally when you get back to the gdb prompt type backtrace.

I hope this helps.




On Wednesday 26 February 2003 05:42 pm, Richard Dale wrote:
> On Wednesday 26 February 2003 1:39 pm, Felix Rodriguez wrote:
> > Thanks for the help. For now I'll use QFileDialog in my code as a work
> > around. Once this problem is resolved in the stable kde release, I'll
> > change it back to KFileDialog. Thanks for the java bindings. I find the
> > combination of java and Qt much easier to work with than C++ and Qt.
>
> Yes, perhaps using QFileDialog is the best thing to do for now. All this
> trouble with dynamic_casts is a good example of why I don't like C++ much
> either - the RTTI stuff seems bolted on as an afterthought.
>
> But if you can test the patch, and confirm it fixes the KFileDialog problem
> and doesn't have any side effects and KDE 3.1 works normally, that would be
> helpful with justifying the fix on the kde-core-devel list.
>
> Another work round might be to build the app with gcj and release it as
> native code. If anyone can try a gcj compiled app with a getOpenFileName
> dialog (eg KScribble), I would be very interested to know if it has the
> dynamic_cast crash problem  or not.
>
> BTW: how do you get a nice C++ stack trace of a crash with java - I haven't
> been able to run java apps under gdb to do that?
>


> -- Richard
>
> > At 10:45 AM 2/26/2003 +0000, you wrote:
> > >On Tuesday 25 February 2003 6:17 pm, Felix Rodriguez wrote:
> > > >     Thanks for the solution. I'll test it out on my system and see
> > > > how it goes.
> > >
> > >Oops - I've just found I've got some of the files round the wrong way in
> > > the patch sorry -  please find a second patch attached.
> > >
> > > > 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?
> > >
> > >Yes, I'll mail the kde-core-devl list when I've done some more
> > >investigation -
> > >it's pretty much a 'showstopper' if you can't open and save files in a
> > > KDE java app. You have a very recent gcc, and I have an old gcc 2.95
> > > version so it seems to affect all compiler versions. I had a similar
> > > problem with a dynamic_cast about a year ago in the KStyle code, but
> > > that was just one of them in a single source file. This time nearly all
> > > (or possibly all) of the casts don't seem to be working with java.
> > >
> > >There are still dynamic_casts that can't be converted to qt_casts
> > > because the target of the cast wasn't a QObject - we need to find if
> > > those are going to be a problem. And I'm not sure if all dynamic_casts
> > > in kdelibs crash in a java app, or just some of them yet.
> > >
> > >-- Richard
> > >
> > > > 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_Stri
> > > > > > >ng _2Lj ava_ 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
> > > >
> > > >
> > > > _______________________________________________
> > > > 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
> >
> >
> > _______________________________________________
> > 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