patch: ktoolbar and kfiledialog

Simon Hausmann hausmann at kde.org
Tue Sep 23 09:39:29 BST 2003


Hi,

in an attempt to get rid of the ugly insertCombo( ..., 33333 );
tb->getCombo( 33333 ) in KFileDialog I ran into a little ktoolbar
bug:

When inserting an item while not specifying an index, the newly
resulting index is calculated wrong. If we append the item in that
case, the new index is count() before the actual appending, I
believe. Can someone review that patch?

The second attachment is the 33333 cleanup. A no-brainer I think,
but better reviewed than sorry :)

Simon
-------------- next part --------------
Index: ktoolbar.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktoolbar.cpp,v
retrieving revision 1.365
diff -u -p -b -r1.365 ktoolbar.cpp
--- ktoolbar.cpp	13 Sep 2003 11:44:56 -0000	1.365
+++ ktoolbar.cpp	23 Sep 2003 08:36:02 -0000
@@ -1343,8 +1343,8 @@ void KToolBar::insertWidgetInternal( QWi
     connect( w, SIGNAL( destroyed() ),
              this, SLOT( widgetDestroyed() ) );
     if ( index == -1 || index > (int)widgets.count() ) {
-        widgets.append( w );
         index = (int)widgets.count();
+        widgets.append( w );
     }
     else
         widgets.insert( index, w );
-------------- next part --------------
Index: kfiledialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kfiledialog.cpp,v
retrieving revision 1.359
diff -u -p -b -r1.359 kfiledialog.cpp
--- kfiledialog.cpp	23 Sep 2003 06:06:07 -0000	1.359
+++ kfiledialog.cpp	23 Sep 2003 08:32:55 -0000
@@ -190,8 +190,9 @@ KFileDialog::KFileDialog(const QString& 
     setOperationMode(Saving);
     }
 
-  toolBar()->insertCombo(QStringList(), 33333, false, 0L, 0L, 0L, true);
-  d->encoding = toolBar()->getCombo(33333);
+  KToolBar *tb = toolBar();
+  int index = tb->insertCombo(QStringList(), -1 /*id*/, false /*writable*/ );
+  d->encoding = tb->getCombo( tb->idAt( index ) );
 
   d->encoding->clear ();
   QString sEncoding = encoding;


More information about the kde-core-devel mailing list