Mercurial > hg > octave-nkf
comparison libgui/src/m-editor/file-editor.cc @ 16637:b3f4bdd7e5f4
fix endless loop when closing all files in the editor and files are modified
* file_editor.cc(request_close_all_files,request_close_other_files):
delete the tabs starting with the last otherwise deleting changes the indexes
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 11 May 2013 14:01:15 +0200 |
parents | 25e418d23a4b |
children | 3c2e457eeb72 |
comparison
equal
deleted
inserted
replaced
16636:d788ee8b8a99 | 16637:b3f4bdd7e5f4 |
---|---|
630 } | 630 } |
631 | 631 |
632 void | 632 void |
633 file_editor::request_close_all_files (bool) | 633 file_editor::request_close_all_files (bool) |
634 { | 634 { |
635 int index; | 635 // loop over all tabs starting from last one otherwise deletion changes index |
636 while ((index = _tab_widget->currentIndex ()) > -1) | 636 for (int index = _tab_widget->count ()-1; index >= 0; index--) |
637 emit fetab_close_request (_tab_widget->widget (index)); | 637 emit fetab_close_request (_tab_widget->widget (index)); |
638 } | 638 } |
639 | 639 |
640 void | 640 void |
641 file_editor::request_close_other_files (bool) | 641 file_editor::request_close_other_files (bool) |
642 { | 642 { |
643 int index = 0; | |
644 QWidget *tabID = _tab_widget->currentWidget (); | 643 QWidget *tabID = _tab_widget->currentWidget (); |
645 | 644 // loop over all tabs starting from last one otherwise deletion changes index |
646 while (_tab_widget->count () > 1) | 645 for (int index = _tab_widget->count ()-1; index >= 0; index--) |
647 { | 646 { |
648 if (tabID != _tab_widget->widget (index)) | 647 if (tabID != _tab_widget->widget (index)) |
649 emit fetab_close_request (_tab_widget->widget (index)); | 648 emit fetab_close_request (_tab_widget->widget (index)); |
650 else | |
651 index++; | |
652 } | 649 } |
653 } | 650 } |
654 | 651 |
655 | 652 |
656 void | 653 void |