PAGED_DIALOG: fix an issue related to TransferDataFromWindow and TransferDataToWindow, on wxWidgets 3.0

On wxWidgets 3.1 they are called recursively but not on on wxWidgets 3.0.
We call now TransferDataToWindow and TransferDataFromWindow only once,
but ensure it is called for all pages.

Fixes: lp:1836901
https://bugs.launchpad.net/kicad/+bug/1836901
This commit is contained in:
jean-pierre charras 2019-07-17 16:46:25 +02:00
parent e5463b5455
commit c84c10fa06
1 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -141,10 +141,14 @@ bool PAGED_DIALOG::TransferDataToWindow()
{ {
finishInitialization(); finishInitialization();
#if 1 // Call TransferDataToWindow() only once: this is enough // Call TransferDataToWindow() only once:
// this is enough on wxWidgets 3.1
if( !DIALOG_SHIM::TransferDataToWindow() ) if( !DIALOG_SHIM::TransferDataToWindow() )
return false; return false;
#else
// On wxWidgets 3.0, TransferDataFromWindow() is not called recursively
// so we have to call it for each page
#if !wxCHECK_VERSION( 3, 1, 0 )
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
{ {
wxWindow* page = m_treebook->GetPage( i ); wxWindow* page = m_treebook->GetPage( i );
@ -152,7 +156,7 @@ bool PAGED_DIALOG::TransferDataToWindow()
if( !page->TransferDataToWindow() ) if( !page->TransferDataToWindow() )
return false; return false;
} }
#endif #endif
// Search for a page matching the lastParentPageTitle/lastPageTitle hierarchy // Search for a page matching the lastParentPageTitle/lastPageTitle hierarchy
wxString lastPage = g_lastPage[ m_title ]; wxString lastPage = g_lastPage[ m_title ];
@ -186,10 +190,14 @@ bool PAGED_DIALOG::TransferDataToWindow()
bool PAGED_DIALOG::TransferDataFromWindow() bool PAGED_DIALOG::TransferDataFromWindow()
{ {
#if 1 // Call TransferDataFromWindow() only once: this is enough // Call TransferDataFromWindow() only once:
// this is enough on wxWidgets 3.1
if( !DIALOG_SHIM::TransferDataFromWindow() ) if( !DIALOG_SHIM::TransferDataFromWindow() )
return false; return false;
#else
// On wxWidgets 3.0, TransferDataFromWindow() is not called recursively
// so we have to call it for each page
#if !wxCHECK_VERSION( 3, 1, 0 )
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
{ {
wxWindow* page = m_treebook->GetPage( i ); wxWindow* page = m_treebook->GetPage( i );
@ -197,7 +205,7 @@ bool PAGED_DIALOG::TransferDataFromWindow()
if( !page->TransferDataFromWindow() ) if( !page->TransferDataFromWindow() )
return false; return false;
} }
#endif #endif
return true; return true;
} }