← Back to team overview

kicad-developers team mailing list archive

[PATCH] IsSingleLine() assertions failing in eeschema, pcbnew, and PCB calculator

 

Hi all,

I've been getting the assertion "IsSingleLine() failed in GetEditable():
shouldn't be called for multiline" in a number of places. This is caused by
a textbox->SetMaxLength() call which GTK doesn't allow on multi-line text
boxes. According to [1] earlier versions of GTK did the check and ignored
the request rather than asserting on it.

There are two bugs on the tracker [2,3] reporting this assertion in
different places, and with the aid of grep I've found several other
occurrences:

Eeschema:

* Adding or editing a net label
* Electrical rules checker
* Plotting the schematic

PCB calculator:

* On opening the calculator

Pcbnew:

* Change footprints (from the footprint properties dialog)
* Adding or editing text (not designators etc)

The source for all of these is in files generated by wxFormBuilder. The
attached patch fixes this by removing the call from the relevant *_base.cpp
files and changing the maxlength property to be empty rather than zero in
the corresponding .fpb files.

In all cases, the argument to SetMaxLength is zero. According to the
wxWidgets docs [4], "if len is 0, the previously set max length limit, if
any, is discarded and the user may enter as much text as the underlying
native text control widget supports (typically at least 32Kb)".  Since the
calls this patch removes are being made on initialisation, I imagine there
is no pre-existing length limit, and therefore no side-effects on non-GTK
backends in removing the calls. Additionally, JP Charras made an identical
change to fix a dialog in revision 4912 which has not been reverted so I
assume this fix is OK. However, if somebody who is in a position to confirm
this can do so that would be appreciated.

A number of other dialogs which use multi-line textboxes are OK -- I'm not
sure if they have been manually fixed previously, or were created with a
newer version of wxFormBuilder which no longer outputs this code. The
discussion in [1] decides it is a wxFB bug but I'm not sure if it was
accepted as such and fixed.

Suggested commit message if accepted:

"""
Remove calls to SetMaxLength() on multi-line textboxes (fixes lp:1168902,
fixes lp:1167345).

This fixes a number of assertions when using wxGTK, and has no side-effects
on other backends.
"""

Cheers
Blair

[1]: http://trac.wxwidgets.org/ticket/14594#comment:2
[2]: https://bugs.launchpad.net/kicad/+bug/1168902
[3]: https://bugs.launchpad.net/kicad/+bug/1167345
[4]:
http://docs.wxwidgets.org/3.0/classwx_text_entry.html#a5b9dea0d1adeb9cc14309600de6aff50
=== modified file 'eeschema/dialogs/dialog_edit_label_base.cpp'
--- eeschema/dialogs/dialog_edit_label_base.cpp	2014-07-29 16:38:27 +0000
+++ eeschema/dialogs/dialog_edit_label_base.cpp	2014-11-03 09:37:27 +0000
@@ -37,7 +37,6 @@
 	bSizeText->Add( m_textLabelSingleLine, 0, wxEXPAND|wxLEFT, 3 );
 	
 	m_textLabelMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_PROCESS_ENTER );
-	m_textLabelMultiLine->SetMaxLength( 0 ); 
 	m_textLabelMultiLine->SetMinSize( wxSize( -1,60 ) );
 	
 	bSizeText->Add( m_textLabelMultiLine, 1, wxEXPAND|wxLEFT, 3 );

=== modified file 'eeschema/dialogs/dialog_edit_label_base.fbp'
--- eeschema/dialogs/dialog_edit_label_base.fbp	2014-07-29 16:38:27 +0000
+++ eeschema/dialogs/dialog_edit_label_base.fbp	2014-11-03 09:37:22 +0000
@@ -327,7 +327,7 @@
                                         <property name="max_size"></property>
                                         <property name="maximize_button">0</property>
                                         <property name="maximum_size"></property>
-                                        <property name="maxlength">0</property>
+                                        <property name="maxlength"></property>
                                         <property name="min_size"></property>
                                         <property name="minimize_button">0</property>
                                         <property name="minimum_size">-1,60</property>

=== modified file 'eeschema/dialogs/dialog_erc_base.cpp'
--- eeschema/dialogs/dialog_erc_base.cpp	2014-10-08 22:40:39 +0000
+++ eeschema/dialogs/dialog_erc_base.cpp	2014-11-03 09:50:17 +0000
@@ -80,7 +80,6 @@
 	bSizerMessages->Add( m_titleMessages, 0, wxRIGHT|wxLEFT, 5 );
 	
 	m_MessagesList = new wxTextCtrl( m_PanelERC, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
-	m_MessagesList->SetMaxLength( 0 ); 
 	bSizerMessages->Add( m_MessagesList, 1, wxEXPAND|wxLEFT, 5 );
 	
 	

=== modified file 'eeschema/dialogs/dialog_erc_base.fbp'
--- eeschema/dialogs/dialog_erc_base.fbp	2014-10-08 22:40:39 +0000
+++ eeschema/dialogs/dialog_erc_base.fbp	2014-11-03 09:50:00 +0000
@@ -1032,7 +1032,7 @@
                                                             <property name="max_size"></property>
                                                             <property name="maximize_button">0</property>
                                                             <property name="maximum_size"></property>
-                                                            <property name="maxlength">0</property>
+                                                            <property name="maxlength"></property>
                                                             <property name="min_size"></property>
                                                             <property name="minimize_button">0</property>
                                                             <property name="minimum_size">-1,-1</property>

=== modified file 'eeschema/dialogs/dialog_plot_schematic_base.cpp'
--- eeschema/dialogs/dialog_plot_schematic_base.cpp	2014-11-02 16:25:04 +0000
+++ eeschema/dialogs/dialog_plot_schematic_base.cpp	2014-11-03 09:50:35 +0000
@@ -146,7 +146,6 @@
 	bSizer4->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
 	
 	m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
-	m_MessagesBox->SetMaxLength( 0 ); 
 	m_MessagesBox->SetMinSize( wxSize( -1,80 ) );
 	
 	bSizer4->Add( m_MessagesBox, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );

=== modified file 'eeschema/dialogs/dialog_plot_schematic_base.fbp'
--- eeschema/dialogs/dialog_plot_schematic_base.fbp	2014-11-02 16:25:04 +0000
+++ eeschema/dialogs/dialog_plot_schematic_base.fbp	2014-11-03 09:50:54 +0000
@@ -1799,7 +1799,7 @@
                                 <property name="max_size"></property>
                                 <property name="maximize_button">0</property>
                                 <property name="maximum_size"></property>
-                                <property name="maxlength">0</property>
+                                <property name="maxlength"></property>
                                 <property name="min_size"></property>
                                 <property name="minimize_button">0</property>
                                 <property name="minimum_size">-1,80</property>

=== modified file 'pcb_calculator/dialogs/pcb_calculator_frame_base.cpp'
--- pcb_calculator/dialogs/pcb_calculator_frame_base.cpp	2014-04-02 13:38:59 +0000
+++ pcb_calculator/dialogs/pcb_calculator_frame_base.cpp	2014-11-03 09:39:42 +0000
@@ -1140,7 +1140,6 @@
 	bMiddleSizerAtt->Add( m_staticTextAttMsg, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
 	
 	m_Attenuator_Messages = new wxTextCtrl( m_panelAttenuators, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
-	m_Attenuator_Messages->SetMaxLength( 0 ); 
 	bMiddleSizerAtt->Add( m_Attenuator_Messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
 	
 	

=== modified file 'pcb_calculator/dialogs/pcb_calculator_frame_base.fbp'
--- pcb_calculator/dialogs/pcb_calculator_frame_base.fbp	2014-04-02 13:38:59 +0000
+++ pcb_calculator/dialogs/pcb_calculator_frame_base.fbp	2014-11-03 09:39:59 +0000
@@ -16799,7 +16799,7 @@
                                                     <property name="max_size"></property>
                                                     <property name="maximize_button">0</property>
                                                     <property name="maximum_size"></property>
-                                                    <property name="maxlength">0</property>
+                                                    <property name="maxlength"></property>
                                                     <property name="min_size"></property>
                                                     <property name="minimize_button">0</property>
                                                     <property name="minimum_size"></property>

=== modified file 'pcbnew/dialogs/dialog_exchange_modules_base.cpp'
--- pcbnew/dialogs/dialog_exchange_modules_base.cpp	2014-10-12 15:12:02 +0000
+++ pcbnew/dialogs/dialog_exchange_modules_base.cpp	2014-11-03 10:06:31 +0000
@@ -87,7 +87,6 @@
 	bMainSizer->Add( m_staticTextMsg, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
 	
 	m_WinMessages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
-	m_WinMessages->SetMaxLength( 0 ); 
 	m_WinMessages->SetMinSize( wxSize( 450,300 ) );
 	
 	bMainSizer->Add( m_WinMessages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );

=== modified file 'pcbnew/dialogs/dialog_exchange_modules_base.fbp'
--- pcbnew/dialogs/dialog_exchange_modules_base.fbp	2014-10-12 15:12:02 +0000
+++ pcbnew/dialogs/dialog_exchange_modules_base.fbp	2014-11-03 10:07:00 +0000
@@ -1219,7 +1219,7 @@
                         <property name="max_size"></property>
                         <property name="maximize_button">0</property>
                         <property name="maximum_size"></property>
-                        <property name="maxlength">0</property>
+                        <property name="maxlength"></property>
                         <property name="min_size"></property>
                         <property name="minimize_button">0</property>
                         <property name="minimum_size">450,300</property>

=== modified file 'pcbnew/dialogs/dialog_pcb_text_properties_base.cpp'
--- pcbnew/dialogs/dialog_pcb_text_properties_base.cpp	2013-09-03 12:48:38 +0000
+++ pcbnew/dialogs/dialog_pcb_text_properties_base.cpp	2014-11-03 10:08:33 +0000
@@ -26,7 +26,6 @@
 	bSizer9->Add( m_TextLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
 	
 	m_TextContentCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
-	m_TextContentCtrl->SetMaxLength( 0 ); 
 	m_TextContentCtrl->SetToolTip( _("Enter the text placed on selected layer.") );
 	m_TextContentCtrl->SetMinSize( wxSize( 400,60 ) );
 	

=== modified file 'pcbnew/dialogs/dialog_pcb_text_properties_base.fbp'
--- pcbnew/dialogs/dialog_pcb_text_properties_base.fbp	2013-09-03 12:48:38 +0000
+++ pcbnew/dialogs/dialog_pcb_text_properties_base.fbp	2014-11-03 10:08:47 +0000
@@ -218,7 +218,7 @@
                                 <property name="max_size"></property>
                                 <property name="maximize_button">0</property>
                                 <property name="maximum_size"></property>
-                                <property name="maxlength">0</property>
+                                <property name="maxlength"></property>
                                 <property name="min_size"></property>
                                 <property name="minimize_button">0</property>
                                 <property name="minimum_size">400,60</property>


Follow ups