Prevent duplicate widget in the close widget list

This commit is contained in:
Markus Gans 2021-05-13 13:17:03 +02:00
parent af5ec304d8
commit 7462c60cfd
4 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,6 @@
2021-05-13 Markus Gans <guru.mail@muenster.de>
* Prevent duplicate widget in the close widget list
2021-05-07 Markus Gans <guru.mail@muenster.de>
* Some pointers were replaced by references

View File

@ -851,7 +851,7 @@ bool FWidget::close()
{
hide();
if ( ! flags.modal )
if ( ! flags.modal && ! isInFWidgetList(close_widget, this) )
close_widget->push_back(this);
}

View File

@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <algorithm>
#include "final/fapplication.h"
#include "final/fcolorpair.h"
#include "final/fstatusbar.h"
@ -53,6 +55,16 @@ bool isFocusPrevKey (const FKey key)
return false;
}
//----------------------------------------------------------------------
bool isInFWidgetList (const FWidget::FWidgetList* list, const FWidget* obj)
{
if ( ! list || ! obj )
return false;
return std::any_of ( list->begin(), list->end()
, [&obj] (FWidget* w) { return w == obj; } );
}
//----------------------------------------------------------------------
FApplication* getFApplication()
{

View File

@ -507,6 +507,7 @@ class FWidget : public FVTerm, public FObject
void detectTermSize();
bool isFocusNextKey (const FKey);
bool isFocusPrevKey (const FKey);
bool isInFWidgetList (const FWidget::FWidgetList*, const FWidget*);
FKey getHotkey (const FString&);
std::size_t getHotkeyPos (const FString& src, FString& dest);
void setHotkeyViaString (FWidget*, const FString&);