Common: do not conditionally define wxPoint/Size operator<<

Due to an interaction with old (<1.59) versions of Boost, the ostream
operator<< for wxPoint and wxSize is requried to use
BOOST_CHECK_EQUAL_COLLECTIONS (the print_log_value<T> function is not
used by this macro until 1.59).

Because these functions are available in Debug builds, unit tests that
use such functions will break when compiled as Release or
RelWithDebugInfo.

The change here is to not disable these functions in Release builds.

Also, the functions are moved to common.h, to go with other generic
WX "polyfill" functions. Although they might be commonly used by the
EDA_ITEM::Show functions, they are not specifically related to that
class.

Fixes: lp:1830612
* https://bugs.launchpad.net/kicad/+bug/1830612
This commit is contained in:
John Beard 2019-05-28 11:57:30 +01:00
parent 27d097a78c
commit 6b4b2d61f8
4 changed files with 30 additions and 25 deletions

View File

@ -274,22 +274,6 @@ BITMAP_DEF EDA_ITEM::GetMenuImage() const
#if defined(DEBUG)
// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxSize& size )
{
out << " width=\"" << size.GetWidth() << "\" height=\"" << size.GetHeight() << "\"";
return out;
}
// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
{
out << " x=\"" << pt.x << "\" y=\"" << pt.y << "\"";
return out;
}
void EDA_ITEM::ShowDummy( std::ostream& os ) const
{
// XML output:

View File

@ -612,6 +612,20 @@ bool std::less<wxPoint>::operator()( const wxPoint& aA, const wxPoint& aB ) cons
#endif
std::ostream& operator<<( std::ostream& out, const wxSize& size )
{
out << " width=\"" << size.GetWidth() << "\" height=\"" << size.GetHeight() << "\"";
return out;
}
std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
{
out << " x=\"" << pt.x << "\" y=\"" << pt.y << "\"";
return out;
}
/**
* Performance enhancements to file and directory operations.
*

View File

@ -38,15 +38,6 @@
#include <bitmap_types.h>
#include <view/view_item.h>
#if defined(DEBUG)
#include <iostream> // needed for Show()
extern std::ostream& operator <<( std::ostream& out, const wxSize& size );
extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt );
#endif
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.

View File

@ -390,6 +390,22 @@ namespace std
};
}
/**
* Helper function to print the given wxSize to a stream.
*
* Used for debugging functions like EDA_ITEM::Show and also in unit
* testing fixtures.
*/
std::ostream& operator<<( std::ostream& out, const wxSize& size );
/**
* Helper function to print the given wxPoint to a stream.
*
* Used for debugging functions like EDA_ITEM::Show and also in unit
* testing fixtures.
*/
std::ostream& operator<<( std::ostream& out, const wxPoint& pt );
/**
* A wrapper around a wxFileName which is much more performant with a subset of the API.