Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YComboBox addItem/addItems become very slow when the number of items is big #49

Open
anaselli opened this issue Sep 8, 2014 · 7 comments
Labels
other-maintainer Not maintained by the core YaST team

Comments

@anaselli
Copy link
Contributor

anaselli commented Sep 8, 2014

I tested it with 2000 and i got it running after a while, qt and ncurses seem not to be affected.
I gave up waiting, with a bigger number (11821 items)

To test it patch ManyWidgets,cc as following:

diff --git a/examples/ManyWidgets.cc b/examples/ManyWidgets.cc
index 743def1..a7e3d92 100644
--- a/examples/ManyWidgets.cc
+++ b/examples/ManyWidgets.cc
@@ -298,9 +298,15 @@ int main( int argc, char **argv )
     cbox->setNotify( true );
     {
       YItemCollection items;
-      items.push_back( new YItem( "Item 1" ) );
-      items.push_back( new YItem( "Item 2" ) );
-      items.push_back( new YItem( "Item 3" ) );
+      for (int i=0; i<11822;i++)
+      {
+        std::stringstream str;
+        str << "Item " << i;
+        items.push_back( new YItem( str.str() ) );
+      }
+//       items.push_back( new YItem( "Item 1" ) );
+//       items.push_back( new YItem( "Item 2" ) );
+//       items.push_back( new YItem( "Item 3" ) );
       cbox->addItems( items ); // This is more efficient than repeatedly calling cbox->addItem
     }
     cbox               = YUI::widgetFactory()->createComboBox( atLeft(frame), "Editable:", true );
@mvidner
Copy link
Member

mvidner commented Sep 12, 2014

I can reproduce the issue but unfortunately I cannot help much, because I don't know GTK.

From the libyui side, YSelectionWidget::addItems calls YSelectionWidget::addItem repeatedly, but also guards this with YWidget::startMultipleChanges and YWidget::doneMultipleChanges (via OptimizeChanges. Perhaps YGSELECTION_WIDGET_IMPL::addItem could take advantage of that.

@anaselli
Copy link
Contributor Author

@mvidner i haven't understood if you mean to add start/end Multiple selection into gtk implementation or not, but i can confirm that adding that for the combobox widget defintely increase the performance.
qt is better in any cases, but with that trick now the program is usable

@mvidner
Copy link
Member

mvidner commented Sep 12, 2014

No, I don't plan to fix it now. Go ahead, and mention here the patch that has helped.

@anaselli
Copy link
Contributor Author

i didn't fix anything :) just used the xxxxMultipleChanges methods on combo:

diff --git a/examples/ManyWidgets.cc b/examples/ManyWidgets.cc
index 743def1..d645fe5 100644
--- a/examples/ManyWidgets.cc
+++ b/examples/ManyWidgets.cc
@@ -298,10 +298,15 @@ int main( int argc, char **argv )
     cbox->setNotify( true );
     {
       YItemCollection items;
-      items.push_back( new YItem( "Item 1" ) );
-      items.push_back( new YItem( "Item 2" ) );
-      items.push_back( new YItem( "Item 3" ) );
+      for (int i=0; i<11822;i++)
+      {
+         std::stringstream str;
+         str << "Item " << i;
+         items.push_back( new YItem( str.str() ) );
+      }
+      cbox->startMultipleChanges();
       cbox->addItems( items ); // This is more efficient than repeatedly calling cbox->addItem
+      cbox->doneMultipleChanges();
     }
     cbox               = YUI::widgetFactory()->createComboBox( atLeft(frame), "Editable:", true );
     cbox->setNotify( true );

@mvidner
Copy link
Member

mvidner commented Sep 12, 2014

That is strange, I thought cbox->addItems already did call those.

@anaselli
Copy link
Contributor Author

I see, but if you try my patch, you should easy verify what i mean :/

@ancorgs
Copy link

ancorgs commented Mar 17, 2021

Since the Gtk backend is not developed or maintained by the YaST Team at SUSE, I'm adding the "other-maintainer" label to this in order to help filtering the various list of issues.

@ancorgs ancorgs added the other-maintainer Not maintained by the core YaST team label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other-maintainer Not maintained by the core YaST team
Projects
None yet
Development

No branches or pull requests

3 participants