diff options
author | Shane Wang <shane.wang@intel.com> | 2012-02-29 22:14:59 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-01 15:51:30 +0000 |
commit | b8582dc99660b5c3c666ccd0ec835b14170c0803 (patch) | |
tree | 73180807d1a4cc7a4fbbc20ee13497bee074d492 /bitbake | |
parent | 030ba4bc71a1e7ea9a74e819949e5fb794af09f2 (diff) | |
download | poky-b8582dc99660b5c3c666ccd0ec835b14170c0803.tar.gz |
Hob: avoid the image selection dialog to walk through all directories and its sub-directories, when users click "My images".
The current implementation of the image selection dialog walks through all directories and its sub-directories, when users click "My images" to choose a directory. If the directory is /, the system becomes slow. This patch is to avoid walking through all directories but the child directories only, given a directory.
(Bitbake rev: 536fa633b442ff37d43f45cf346ba281d69de496)
Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 8f4f7cdf04..9aa6fdf815 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -582,6 +582,7 @@ class ImageSelectionDialog (gtk.Dialog): | |||
582 | 582 | ||
583 | self.image_folder = image_folder | 583 | self.image_folder = image_folder |
584 | self.image_types = image_types | 584 | self.image_types = image_types |
585 | self.image_list = [] | ||
585 | self.image_names = [] | 586 | self.image_names = [] |
586 | 587 | ||
587 | # create visual elements on the dialog | 588 | # create visual elements on the dialog |
@@ -645,13 +646,17 @@ class ImageSelectionDialog (gtk.Dialog): | |||
645 | dialog.destroy() | 646 | dialog.destroy() |
646 | 647 | ||
647 | def fill_image_store(self): | 648 | def fill_image_store(self): |
649 | self.image_list = [] | ||
648 | self.image_store.clear() | 650 | self.image_store.clear() |
649 | imageset = set() | 651 | imageset = set() |
650 | for root, dirs, files in os.walk(self.image_folder): | 652 | for root, dirs, files in os.walk(self.image_folder): |
653 | # ignore the sub directories | ||
654 | dirs[:] = [] | ||
651 | for f in files: | 655 | for f in files: |
652 | for image_type in self.image_types: | 656 | for image_type in self.image_types: |
653 | if f.endswith('.' + image_type): | 657 | if f.endswith('.' + image_type): |
654 | imageset.add(f.rsplit('.' + image_type)[0]) | 658 | imageset.add(f.rsplit('.' + image_type)[0]) |
659 | self.image_list.append(f) | ||
655 | 660 | ||
656 | for image in imageset: | 661 | for image in imageset: |
657 | self.image_store.set(self.image_store.append(), 0, image, 1, False) | 662 | self.image_store.set(self.image_store.append(), 0, image, 1, False) |
@@ -665,9 +670,8 @@ class ImageSelectionDialog (gtk.Dialog): | |||
665 | while iter: | 670 | while iter: |
666 | path = self.image_store.get_path(iter) | 671 | path = self.image_store.get_path(iter) |
667 | if self.image_store[path][1]: | 672 | if self.image_store[path][1]: |
668 | for root, dirs, files in os.walk(self.image_folder): | 673 | for f in self.image_list: |
669 | for f in files: | 674 | if f.startswith(self.image_store[path][0] + '.'): |
670 | if f.startswith(self.image_store[path][0] + '.'): | 675 | self.image_names.append(f) |
671 | self.image_names.append(f) | ||
672 | break | 676 | break |
673 | iter = self.image_store.iter_next(iter) | 677 | iter = self.image_store.iter_next(iter) |