Smarten isEmpty checks to include nothing-but-whitespace.
Fixes https://gitlab.com/kicad/code/kicad/issues/6567
This commit is contained in:
parent
d50d1d84da
commit
3c521942ed
|
@ -362,6 +362,12 @@ wxString EscapeHTML( const wxString& aString )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool NoPrintableChars( wxString aString )
|
||||||
|
{
|
||||||
|
return aString.Trim( true ).Trim( false ).IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char* StrPurge( char* text )
|
char* StrPurge( char* text )
|
||||||
{
|
{
|
||||||
static const char whitespace[] = " \t\n\r\f\v";
|
static const char whitespace[] = " \t\n\r\f\v";
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <symbol_editor/symbol_editor_settings.h>
|
#include <symbol_editor/symbol_editor_settings.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
#include "ee_point_editor.h"
|
#include "ee_point_editor.h"
|
||||||
|
|
||||||
static void* g_lastPinWeakPtr;
|
static void* g_lastPinWeakPtr;
|
||||||
|
@ -181,7 +182,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
DIALOG_LIB_EDIT_TEXT dlg( m_frame, text );
|
DIALOG_LIB_EDIT_TEXT dlg( m_frame, text );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
|
||||||
delete text;
|
delete text;
|
||||||
else
|
else
|
||||||
item = text;
|
item = text;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "sch_drawing_tools.h"
|
#include "sch_drawing_tools.h"
|
||||||
#include "ee_selection_tool.h"
|
#include "ee_selection_tool.h"
|
||||||
#include "ee_point_editor.h"
|
|
||||||
#include <ee_actions.h>
|
#include <ee_actions.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
|
@ -48,6 +47,7 @@
|
||||||
#include <dialogs/dialog_edit_line_style.h>
|
#include <dialogs/dialog_edit_line_style.h>
|
||||||
#include <dialogs/dialog_junction_props.h>
|
#include <dialogs/dialog_junction_props.h>
|
||||||
#include <dialogs/dialog_sheet_pin_properties.h>
|
#include <dialogs/dialog_sheet_pin_properties.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
|
|
||||||
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
|
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
|
||||||
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
|
||||||
|
@ -733,7 +733,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||||
DIALOG_LABEL_EDITOR dlg( m_frame, textItem );
|
DIALOG_LABEL_EDITOR dlg( m_frame, textItem );
|
||||||
|
|
||||||
// Must be quasi modal for syntax help
|
// Must be quasi modal for syntax help
|
||||||
if( dlg.ShowQuasiModal() != wxID_OK || textItem->GetText().IsEmpty() )
|
if( dlg.ShowQuasiModal() != wxID_OK || NoPrintableChars( textItem->GetText() ) )
|
||||||
{
|
{
|
||||||
delete textItem;
|
delete textItem;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -789,7 +789,7 @@ SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createSheetPin( SCH_SHEET* aSheet, SCH_HIERLAB
|
||||||
{
|
{
|
||||||
DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
|
DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
|
if( dlg.ShowModal() != wxID_OK || NoPrintableChars( sheetPin->GetText() ) )
|
||||||
{
|
{
|
||||||
delete sheetPin;
|
delete sheetPin;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -115,6 +115,11 @@ wxString EscapeHTML( const wxString& aString );
|
||||||
*/
|
*/
|
||||||
char* GetLine( FILE* aFile, char* Line, int* LineNum = NULL, int SizeLine = 255 );
|
char* GetLine( FILE* aFile, char* Line, int* LineNum = NULL, int SizeLine = 255 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the string is empty or contains only whitespace.
|
||||||
|
*/
|
||||||
|
bool NoPrintableChars( wxString aString );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove leading and training spaces, tabs and end of line chars in \a text
|
* Remove leading and training spaces, tabs and end of line chars in \a text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,14 +23,18 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "drawing_tool.h"
|
|
||||||
#include "pcb_actions.h"
|
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <import_gfx/dialog_import_gfx.h>
|
#include <import_gfx/dialog_import_gfx.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tools/pcb_actions.h>
|
||||||
|
#include <tools/grid_helper.h>
|
||||||
|
#include <tools/selection_tool.h>
|
||||||
|
#include <tools/tool_event_utils.h>
|
||||||
|
#include <tools/zone_create_helper.h>
|
||||||
|
#include <tools/drawing_tool.h>
|
||||||
#include <geometry/geometry_utils.h>
|
#include <geometry/geometry_utils.h>
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
#include <scoped_set_reset.h>
|
#include <scoped_set_reset.h>
|
||||||
|
@ -39,24 +43,18 @@
|
||||||
#include <status_popup.h>
|
#include <status_popup.h>
|
||||||
#include <dialogs/dialog_text_properties.h>
|
#include <dialogs/dialog_text_properties.h>
|
||||||
#include <preview_items/arc_assistant.h>
|
#include <preview_items/arc_assistant.h>
|
||||||
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <fp_shape.h>
|
#include <fp_shape.h>
|
||||||
#include <pcb_text.h>
|
#include <pcb_text.h>
|
||||||
#include <dimension.h>
|
#include <dimension.h>
|
||||||
#include <zone.h>
|
#include <zone.h>
|
||||||
#include <footprint.h>
|
#include <footprint.h>
|
||||||
|
|
||||||
#include <preview_items/two_point_assistant.h>
|
#include <preview_items/two_point_assistant.h>
|
||||||
#include <preview_items/two_point_geom_manager.h>
|
#include <preview_items/two_point_geom_manager.h>
|
||||||
#include <ratsnest/ratsnest_data.h>
|
#include <ratsnest/ratsnest_data.h>
|
||||||
#include <tools/grid_helper.h>
|
|
||||||
#include <tools/point_editor.h>
|
|
||||||
#include <tools/selection_tool.h>
|
|
||||||
#include <tools/tool_event_utils.h>
|
|
||||||
#include <tools/zone_create_helper.h>
|
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <dialogs/dialog_track_via_size.h>
|
#include <dialogs/dialog_track_via_size.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
|
|
||||||
using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>;
|
using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>;
|
||||||
|
|
||||||
|
@ -99,11 +97,15 @@ protected:
|
||||||
VIA_DIMENSION via = bds.m_ViasDimensionsList[i];
|
VIA_DIMENSION via = bds.m_ViasDimensionsList[i];
|
||||||
|
|
||||||
if( via.m_Drill > 0 )
|
if( via.m_Drill > 0 )
|
||||||
|
{
|
||||||
msg.Printf( _("Via %s, drill %s" ),
|
msg.Printf( _("Via %s, drill %s" ),
|
||||||
MessageTextFromValue( units, via.m_Diameter ),
|
MessageTextFromValue( units, via.m_Diameter ),
|
||||||
MessageTextFromValue( units, via.m_Drill ) );
|
MessageTextFromValue( units, via.m_Drill ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
msg.Printf( _( "Via %s" ), MessageTextFromValue( units, via.m_Diameter ) );
|
msg.Printf( _( "Via %s" ), MessageTextFromValue( units, via.m_Diameter ) );
|
||||||
|
}
|
||||||
|
|
||||||
int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i;
|
int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i;
|
||||||
Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
|
Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
|
||||||
|
@ -522,11 +524,10 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
RunMainStack( [&]()
|
RunMainStack( [&]()
|
||||||
{
|
{
|
||||||
cancelled = !textDialog.ShowModal()
|
cancelled = !textDialog.ShowModal();
|
||||||
|| fpText->GetText().IsEmpty();
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if( cancelled )
|
if( cancelled || NoPrintableChars( fpText->GetText() ) )
|
||||||
{
|
{
|
||||||
delete text;
|
delete text;
|
||||||
text = nullptr;
|
text = nullptr;
|
||||||
|
@ -560,7 +561,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
m_frame->ShowTextPropertiesDialog( pcbText );
|
m_frame->ShowTextPropertiesDialog( pcbText );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if( pcbText->GetText().IsEmpty() )
|
if( NoPrintableChars( pcbText->GetText() ) )
|
||||||
delete pcbText;
|
delete pcbText;
|
||||||
else
|
else
|
||||||
text = pcbText;
|
text = pcbText;
|
||||||
|
|
Loading…
Reference in New Issue