[Kde-java] Bug in KFileDialog

Richard Dale kde-java@kde.org
Tue, 25 Feb 2003 17:27:46 +0000


--Boundary-00=_Se6W+AXs1tNmXnr
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--Boundary-00=_Se6W+AXs1tNmXnr
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kdelibs_3_1_dyn_to_qt_cast.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kdelibs_3_1_dyn_to_qt_cast.patch"

diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/kaction.cpp kdelibs/kdeui/kaction.cpp
--- tmp/kdeui/kaction.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/kaction.cpp	Tue Feb 25 15:13:06 2003
@@ -297,7 +297,7 @@
 
     d->m_cutDefault = cut;
 
-    m_parentCollection = dynamic_cast<KActionCollection *>( parent() );
+    m_parentCollection = ( parent() == 0 ? 0 : (KActionCollection *) ( parent())->qt_cast("KActionCollection"));
     kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl;
     if ( m_parentCollection )
         m_parentCollection->insert( this );
@@ -838,7 +838,7 @@
   while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
     tl = n;
 
-  KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
+  KMainWindow * mw = (tl == 0 ? 0 : (KMainWindow *) (tl)->qt_cast("KMainWindow")); // try to see if it's a kmainwindow
   if (mw)
     plugAccel( mw->accel() );
   else
@@ -1057,12 +1057,12 @@
 
 KToolBar* KAction::toolBar( int index ) const
 {
-    return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container );
+    return ( d->m_containers[ index ].m_container  == 0 ? 0 : (KToolBar *) ( d->m_containers[ index ].m_container )->qt_cast("KToolBar"));
 }
 
 QPopupMenu* KAction::popupMenu( int index ) const
 {
-    return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container );
+    return ( d->m_containers[ index ].m_container  == 0 ? 0 : (QPopupMenu *) ( d->m_containers[ index ].m_container )->qt_cast("QPopupMenu"));
 }
 
 QWidget* KAction::representative( int index ) const
@@ -2880,7 +2880,7 @@
     while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
       tl = n;
 
-    KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
+    KMainWindow * mw = (tl == 0 ? 0 : (KMainWindow *) (tl)->qt_cast("KMainWindow")); // try to see if it's a kmainwindow
 
     if ( mw )
         m_toolBar = mw->toolBar( m_toolBarName );
@@ -3124,7 +3124,7 @@
   kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis
   kdDebug(129) << kdBacktrace() << endl;
   d = new KActionCollectionPrivate;
-  QWidget* w = dynamic_cast<QWidget*>( parent );
+  QWidget* w = ( parent  == 0 ? 0 : (QWidget *) ( parent )->qt_cast("QWidget"));
   if( w )
     setWidget( w );
   //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
@@ -3309,7 +3309,7 @@
   while ( tl->parentWidget() ) // lookup parent and store
     tl = tl->parentWidget();
 
-  KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
+  KMainWindow * mw = (tl == 0 ? 0 : (KMainWindow *) (tl)->qt_cast("KMainWindow")); // try to see if it's a kmainwindow
   if (mw)
     d->m_mainwindow = mw;
   else
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/kcombobox.cpp kdelibs/kdeui/kcombobox.cpp
--- tmp/kdeui/kcombobox.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/kcombobox.cpp	Tue Feb 25 15:13:06 2003
@@ -270,7 +270,7 @@
     }
 
     QComboBox::setLineEdit( edit );
-    d->klineEdit = dynamic_cast<KLineEdit*>( edit );
+    d->klineEdit = ( edit  == 0 ? 0 : (KLineEdit *) ( edit )->qt_cast("KLineEdit"));
     setDelegate( d->klineEdit );
 
     // forward some signals.
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/kcursor.cpp kdelibs/kdeui/kcursor.cpp
--- tmp/kdeui/kcursor.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/kcursor.cpp	Tue Feb 25 15:13:06 2003
@@ -320,7 +320,7 @@
     if ( !w )
         return;
     // Is w a scrollview ? Call setCursor on the viewport in that case.
-    QScrollView * sv = dynamic_cast<QScrollView *>( w );
+    QScrollView * sv = ( w  == 0 ? 0 : (QScrollView *) ( w )->qt_cast("QScrollView"));
     if ( sv )
         w = sv->viewport();
 
@@ -337,7 +337,7 @@
     isCursorHidden = false;
 
     if ( w ) {
-        QScrollView * sv = dynamic_cast<QScrollView *>( w );
+        QScrollView * sv = ( w  == 0 ? 0 : (QScrollView *) ( w )->qt_cast("QScrollView"));
         if ( sv )
             w = sv->viewport();
 
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/kdockwidget.cpp kdelibs/kdeui/kdockwidget.cpp
--- tmp/kdeui/kdockwidget.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/kdockwidget.cpp	Tue Feb 25 15:13:06 2003
@@ -2647,7 +2647,7 @@
 //    	QPtrList<QObject> list(children());
 //       QObject *obj=((QPtrList<QObject*>)children())->at(i);
 	QObject *obj=children()->getFirst();
-       if (split=dynamic_cast<KDockSplitter*>(obj))
+       if (split=(obj) == 0 ? 0 : (KDockSplitter *) (obj))->qt_cast("KDockSplitter"))
        {
           split->setGeometry( QRect(QPoint(0,0), size() ));
 //	  break;
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/keditlistbox.cpp kdelibs/kdeui/keditlistbox.cpp
--- tmp/kdeui/keditlistbox.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/keditlistbox.cpp	Tue Feb 25 15:13:06 2003
@@ -385,7 +385,7 @@
 KEditListBox::CustomEditor::CustomEditor( KComboBox *combo )
 {
     m_representationWidget = combo;
-    m_lineEdit = dynamic_cast<KLineEdit*>( combo->lineEdit() );
+    m_lineEdit = ( combo->lineEdit() == 0 ? 0 : (KLineEdit *) ( combo->lineEdit())->qt_cast("KLineEdit"));
     assert( m_lineEdit );
 }
 
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/ktoolbar.cpp kdelibs/kdeui/ktoolbar.cpp
--- tmp/kdeui/ktoolbar.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/ktoolbar.cpp	Tue Feb 25 15:13:06 2003
@@ -452,7 +452,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setPixmap( _pixmap );
 }
@@ -463,7 +463,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setIcon( _icon );
 }
@@ -473,7 +473,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setIconSet( iconset );
 }
@@ -484,7 +484,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setDelayedPopup( _popup, toggle );
 }
@@ -495,7 +495,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setAutoRepeat( flag );
 }
@@ -506,7 +506,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->setToggle( flag );
 }
@@ -517,7 +517,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->toggle();
 }
@@ -528,7 +528,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if ( button )
         button->on( flag );
 }
@@ -539,7 +539,7 @@
     Id2WidgetMap::ConstIterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return false;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     return button ? button->isOn() : false;
 }
 
@@ -549,7 +549,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
+    QLineEdit * lineEdit = ( *it  == 0 ? 0 : (QLineEdit *) ( *it )->qt_cast("QLineEdit"));
     if ( lineEdit )
         lineEdit->setText( text );
 }
@@ -560,7 +560,7 @@
     Id2WidgetMap::ConstIterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return QString::null;
-    QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
+    QLineEdit * lineEdit = ( *it  == 0 ? 0 : (QLineEdit *) ( *it )->qt_cast("QLineEdit"));
     return lineEdit ? lineEdit->text() : QString::null;
 }
 
@@ -570,7 +570,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->insertItem( text, index );
 }
@@ -580,7 +580,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->insertStringList( list, index );
 }
@@ -591,7 +591,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->removeItem( index );
 }
@@ -602,7 +602,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->setCurrentItem( index );
 }
@@ -613,7 +613,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->changeItem( text, index );
 }
@@ -624,7 +624,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     if (comboBox)
         comboBox->clear();
 }
@@ -635,7 +635,7 @@
     Id2WidgetMap::ConstIterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return QString::null;
-    QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
+    QComboBox * comboBox = ( *it  == 0 ? 0 : (QComboBox *) ( *it )->qt_cast("QComboBox"));
     return comboBox ? comboBox->text( index ) : QString::null;
 }
 
@@ -645,7 +645,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return 0;
-    return dynamic_cast<KComboBox *>( *it );
+    return ( *it  == 0 ? 0 : (KComboBox *) ( *it )->qt_cast("KComboBox"));
 }
 
 
@@ -654,7 +654,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return 0;
-    return dynamic_cast<KLineEdit *>( *it );
+    return ( *it  == 0 ? 0 : (KLineEdit *) ( *it )->qt_cast("KLineEdit"));
 }
 
 
@@ -663,7 +663,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return 0;
-    return dynamic_cast<KToolBarButton *>( *it );
+    return ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
 }
 
 
@@ -922,7 +922,7 @@
     Id2WidgetMap::Iterator it = id2widget.find( id );
     if ( it == id2widget.end() )
         return;
-    KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
+    KToolBarButton * button = ( *it  == 0 ? 0 : (KToolBarButton *) ( *it )->qt_cast("KToolBarButton"));
     if (button)
         button->setNoStyle( no_style );
 }
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kdeui/ktoolbarhandler.cpp kdelibs/kdeui/ktoolbarhandler.cpp
--- tmp/kdeui/ktoolbarhandler.cpp	Tue Feb 25 17:06:58 2003
+++ kdelibs/kdeui/ktoolbarhandler.cpp	Tue Feb 25 15:13:06 2003
@@ -51,7 +51,7 @@
             QPtrListIterator<QDockWindow> dockWindowIt( dockWindows );
             for ( ; dockWindowIt.current(); ++dockWindowIt ) {
 
-                KToolBar *toolBar = dynamic_cast<KToolBar *>( dockWindowIt.current() );
+                KToolBar *toolBar = ( dockWindowIt.current() == 0 ? 0 : (KToolBar *) ( dockWindowIt.current())->qt_cast("KToolBar"));
                 if ( !toolBar )
                     continue;
 
@@ -229,7 +229,7 @@
 
 void ToolBarHandler::connectToActionContainer( QWidget *container )
 {
-    QPopupMenu *popupMenu = dynamic_cast<QPopupMenu *>( container );
+    QPopupMenu *popupMenu = ( container  == 0 ? 0 : (QPopupMenu *) ( container )->qt_cast("QPopupMenu"));
     if ( !popupMenu )
         return;
 
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kio/kfile/kdiroperator.cpp kdelibs/kio/kfile/kdiroperator.cpp
--- tmp/kio/kfile/kdiroperator.cpp	Tue Feb 25 16:04:59 2003
+++ kdelibs/kio/kfile/kdiroperator.cpp	Tue Feb 25 17:07:41 2003
@@ -1357,7 +1357,7 @@
     bool appSpecificPreview = false;
     if ( myPreview ) {
         QWidget *preview = const_cast<QWidget*>( myPreview ); // grmbl
-        KImageFilePreview *tmp = ( preview  == 0 ? 0 : (KImageFilePreview *) ( preview )->qt_cast("KImageFilePreview"));
+        KImageFilePreview *tmp = dynamic_cast<KImageFilePreview*>( preview );
         appSpecificPreview = (tmp == 0L);
     }
 
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kio/kfile/kpropertiesdialog.cpp kdelibs/kio/kfile/kpropertiesdialog.cpp
--- tmp/kio/kfile/kpropertiesdialog.cpp	Tue Feb 25 16:04:59 2003
+++ kdelibs/kio/kfile/kpropertiesdialog.cpp	Tue Feb 25 17:07:41 2003
@@ -272,7 +272,7 @@
 
     for ( it=m_pageList.first(); it != 0L; it=m_pageList.next() )
     {
-        KFileSharePropsPlugin* plugin = (it == 0 ? 0 : (KFileSharePropsPlugin *) (it)->qt_cast("KFileSharePropsPlugin"));
+        KFileSharePropsPlugin* plugin = dynamic_cast<KFileSharePropsPlugin*>(it);
         if ( plugin )
         {
             showPage( pageIndex( plugin->page() ) );
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kio/kfile/kurlrequester.cpp kdelibs/kio/kfile/kurlrequester.cpp
--- tmp/kio/kfile/kurlrequester.cpp	Tue Feb 25 16:04:59 2003
+++ kdelibs/kio/kfile/kurlrequester.cpp	Tue Feb 25 17:07:41 2003
@@ -124,9 +124,9 @@
         QString txt = combo ? combo->currentText() : edit->text();
         KURLCompletion *comp;
         if ( combo )
-            comp = (combo->completionObject() == 0 ? 0 : (KURLCompletion *) (combo->completionObject())->qt_cast("KURLCompletion"));
+            comp = dynamic_cast<KURLCompletion*>(combo->completionObject());
         else
-            comp = (edit->completionObject() == 0 ? 0 : (KURLCompletion *) (edit->completionObject())->qt_cast("KURLCompletion"));
+            comp = dynamic_cast<KURLCompletion*>(edit->completionObject());
 
         if ( comp )
             return comp->replacedPath( txt );
@@ -150,8 +150,8 @@
 
     // must have this as parent
     editWidget->reparent( this, 0, QPoint(0,0) );
-    d->edit = ( editWidget  == 0 ? 0 : (KLineEdit *) ( editWidget )->qt_cast("KLineEdit"));
-    d->combo = ( editWidget  == 0 ? 0 : (KComboBox *) ( editWidget )->qt_cast("KComboBox"));
+    d->edit = dynamic_cast<KLineEdit*>( editWidget );
+    d->combo = dynamic_cast<KComboBox*>( editWidget );
 
     init();
 }
@@ -334,7 +334,7 @@
 
     KLineEdit *edit = d->edit;
     if ( !edit && d->combo )
-        edit = ( d->combo->lineEdit() == 0 ? 0 : (KLineEdit *) ( d->combo->lineEdit())->qt_cast("KLineEdit"));
+        edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() );
 
 #ifndef NDEBUG
     if ( !edit )
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kio/kio/kscan.cpp kdelibs/kio/kio/kscan.cpp
--- tmp/kio/kio/kscan.cpp	Tue Feb 25 17:04:08 2003
+++ kdelibs/kio/kio/kscan.cpp	Tue Feb 25 16:20:36 2003
@@ -43,7 +43,7 @@
 
     QObject *res = factory->create( parent, name, "KScanDialog", args );
 
-    return dynamic_cast<KScanDialog *>( res );
+    return ( res  == 0 ? 0 : (KScanDialog *) ( res )->qt_cast("KScanDialog"));
 }
 
 
@@ -86,7 +86,7 @@
 
     QObject *res = factory->create( parent, name, "KOCRDialog", args );
 
-    return dynamic_cast<KOCRDialog *>( res );
+    return ( res  == 0 ? 0 : (KOCRDialog *) ( res )->qt_cast("KOCRDialog"));
 }
 
 
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kio/kio/scheduler.cpp kdelibs/kio/kio/scheduler.cpp
--- tmp/kio/kio/scheduler.cpp	Tue Feb 25 17:04:08 2003
+++ kdelibs/kio/kio/scheduler.cpp	Tue Feb 25 16:20:36 2003
@@ -488,7 +488,7 @@
     {
        // Make sure that the job wants to do a GET or a POST, and with no offset
        bool bCanReuse = (job->command() == CMD_GET);
-       KIO::TransferJob * tJob = dynamic_cast<KIO::TransferJob *>(job);
+       KIO::TransferJob * tJob = (job == 0 ? 0 : (KIO::TransferJob *) (job)->qt_cast("KIO::TransferJob"));
        if ( tJob )
        {
           bCanReuse = (job->command() == CMD_GET || job->command() == CMD_SPECIAL);
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kstyles/highcolor/highcolor.cpp kdelibs/kstyles/highcolor/highcolor.cpp
--- tmp/kstyles/highcolor/highcolor.cpp	Tue Feb 25 17:05:22 2003
+++ kdelibs/kstyles/highcolor/highcolor.cpp	Tue Feb 25 16:18:22 2003
@@ -1878,7 +1878,7 @@
 	QToolBar* toolbar;
 
 	// Handle push button hover effects.
-	QPushButton* button = dynamic_cast<QPushButton*>(object);
+	QPushButton* button = (object == 0 ? 0 : (QPushButton *) (object)->qt_cast("QPushButton"));
 	if ( button )
 	{
 		if ( (event->type() == QEvent::Enter) &&
@@ -1914,7 +1914,7 @@
 			bool horiz_grad = pr.width() < pr.height();
 
 			// Check if the parent is a QToolbar, and use its orientation, else guess.
-			QToolBar* tb = dynamic_cast<QToolBar*>(parent);
+			QToolBar* tb = (parent == 0 ? 0 : (QToolBar *) (parent)->qt_cast("QToolBar"));
 			if (tb) horiz_grad = tb->orientation() == Qt::Vertical;
 
 			QPainter p( widget );
@@ -1924,7 +1924,7 @@
 			return false;	// Now draw the contents
 		}
 	} else if ( object->parent() &&
-			(toolbar = dynamic_cast<QToolBar*>(object->parent())) )
+			(toolbar = (object->parent() == 0 ? 0 : (QToolBar *) (object->parent())->qt_cast("QToolBar"))) )
 	{
 		// We need to override the paint event to draw a 
 		// gradient on a QToolBarExtensionWidget.
diff -Naur -X /home/duke/bin/patcher.exclude tmp/kstyles/keramik/keramik.cpp kdelibs/kstyles/keramik/keramik.cpp
--- tmp/kstyles/keramik/keramik.cpp	Tue Feb 25 17:05:34 2003
+++ kdelibs/kstyles/keramik/keramik.cpp	Tue Feb 25 16:15:09 2003
@@ -482,7 +482,7 @@
 				bool horiz_grad = pr.width() > pr.height();
 
 				// Check if the parent is a QToolbar, and use its orientation, else guess.
-				QToolBar* tb = dynamic_cast<QToolBar*>(parent);
+				QToolBar* tb = (parent == 0 ? 0 : (QToolBar *) (parent)->qt_cast("QToolBar"));
 				if (tb) horiz_grad = tb->orientation() == Qt::Horizontal;
 
 				Keramik::GradientPainter::renderGradient( p,
@@ -2373,7 +2373,7 @@
 		bool horiz_grad = pr.width() > pr.height();
 
 		// Check if the parent is a QToolbar, and use its orientation, else guess.
-		QToolBar* tb = dynamic_cast<QToolBar*>(parent);
+		QToolBar* tb = (parent == 0 ? 0 : (QToolBar *) (parent)->qt_cast("QToolBar"));
 		if (tb) horiz_grad = tb->orientation() == Qt::Horizontal;
 		QPainter p( widget );
 

--Boundary-00=_Se6W+AXs1tNmXnr--