Commit 3b9ebd22 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Minor fixes in dialog rescue: missing title, incorrect refresh due to use of a...

Minor fixes in dialog rescue: missing title, incorrect refresh due to use of a wxPaintDC outside a paint event, and coverity warnings (not initialized members).
parent 3084c0aa
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@
#include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h>
#include <wx/tokenzr.h>
#include <wx/tokenzr.h>
#include <dialog_eeschema_config_fbp.h>
#include <dialog_eeschema_config_fbp.h>
#include <eeschema_config.h>




class SCH_EDIT_FRAME;
class SCH_EDIT_FRAME;
@@ -129,7 +130,7 @@ DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( wxWindow* aParent,
    // Load setting for cache rescue
    // Load setting for cache rescue
    m_config = Kiface().KifaceSettings();
    m_config = Kiface().KifaceSettings();
    bool rescueNeverShow = false;
    bool rescueNeverShow = false;
    m_config->Read( wxT("RescueNeverShow"), &rescueNeverShow, false );
    m_config->Read( RESCUE_NEVER_SHOW_KEY, &rescueNeverShow, false );
    m_cbRescue->SetValue( !rescueNeverShow );
    m_cbRescue->SetValue( !rescueNeverShow );


    wxString msg = wxString::Format( _(
    wxString msg = wxString::Format( _(
@@ -249,7 +250,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
        *m_callers_lib_names = list;
        *m_callers_lib_names = list;
    }
    }


    m_config->Write( wxT("RescueNeverShow"), ! m_cbRescue->GetValue() );
    m_config->Write( RESCUE_NEVER_SHOW_KEY, ! m_cbRescue->GetValue() );


    EndModal( wxID_OK );
    EndModal( wxID_OK );
}
}
+12 −14
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@
#include <vector>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/foreach.hpp>
#include <lib_cache_rescue.h>
#include <lib_cache_rescue.h>
#include <eeschema_config.h>


class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE
class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE
{
{
@@ -84,6 +85,7 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, std::vector<RES
      m_AskShowAgain( aAskShowAgain ),
      m_AskShowAgain( aAskShowAgain ),
      m_insideUpdateEvent( false )
      m_insideUpdateEvent( false )
{
{
    m_Config = Kiface().KifaceSettings();
}
}




@@ -97,7 +99,6 @@ bool DIALOG_RESCUE_EACH::TransferDataToWindow()
    if( !wxDialog::TransferDataToWindow() )
    if( !wxDialog::TransferDataToWindow() )
        return false;
        return false;


    m_Config = Kiface().KifaceSettings();
    m_ListOfConflicts->AppendToggleColumn( wxT("Rescue") );
    m_ListOfConflicts->AppendToggleColumn( wxT("Rescue") );
    m_ListOfConflicts->AppendTextColumn( wxT("Symbol Name") );
    m_ListOfConflicts->AppendTextColumn( wxT("Symbol Name") );
    m_ListOfInstances->AppendTextColumn( wxT("Reference") );
    m_ListOfInstances->AppendTextColumn( wxT("Reference") );
@@ -135,6 +136,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
    m_ListOfInstances->DeleteAllItems();
    m_ListOfInstances->DeleteAllItems();


    int row = m_ListOfConflicts->GetSelectedRow();
    int row = m_ListOfConflicts->GetSelectedRow();

    if( row == wxNOT_FOUND )
    if( row == wxNOT_FOUND )
        row = 0;
        row = 0;


@@ -160,6 +162,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent )
void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent )
{
{
    int row = m_ListOfConflicts->GetSelectedRow();
    int row = m_ListOfConflicts->GetSelectedRow();

    if( row == wxNOT_FOUND )
    if( row == wxNOT_FOUND )
        row = 0;
        row = 0;


@@ -172,6 +175,7 @@ void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEven
void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent )
void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent )
{
{
    int row = m_ListOfConflicts->GetSelectedRow();
    int row = m_ListOfConflicts->GetSelectedRow();

    if( row == wxNOT_FOUND )
    if( row == wxNOT_FOUND )
        row = 0;
        row = 0;


@@ -190,6 +194,7 @@ void DIALOG_RESCUE_EACH::OnDialogResize( wxSizeEvent& aSizeEvent )


// Render the preview in our m_componentView. If this gets more complicated, we should
// Render the preview in our m_componentView. If this gets more complicated, we should
// probably have a derived class from wxPanel; but this keeps things local.
// probably have a derived class from wxPanel; but this keeps things local.
// Call it only from a Paint Event, because we are using a wxPaintDC to draw the component
void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel )
void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel )
{
{
    wxPaintDC dc( aPanel );
    wxPaintDC dc( aPanel );
@@ -215,9 +220,7 @@ void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel


    dc.SetUserScale( scale, scale );
    dc.SetUserScale( scale, scale );


    wxPoint offset =  bBox.Centre();
    wxPoint offset = - bBox.Centre();
    NEGATE( offset.x );
    NEGATE( offset.y );


    // Avoid rendering when either dimension is zero
    // Avoid rendering when either dimension is zero
    int width, height;
    int width, height;
@@ -236,18 +239,13 @@ void DIALOG_RESCUE_EACH::OnConflictSelect( wxDataViewEvent& aEvent )
    // wxformbuilder connects this event to the _dialog_, not the data view.
    // wxformbuilder connects this event to the _dialog_, not the data view.
    // Make sure the correct item triggered it, otherwise we trigger recursively
    // Make sure the correct item triggered it, otherwise we trigger recursively
    // and get a stack overflow.
    // and get a stack overflow.
    if( aEvent.GetEventObject() != m_ListOfConflicts ) return;
    if( aEvent.GetEventObject() != m_ListOfConflicts )
        return;


    PopulateInstanceList();
    PopulateInstanceList();


    int row = m_ListOfConflicts->GetSelectedRow();
    m_componentViewOld->Refresh();
    if( row == wxNOT_FOUND )
    m_componentViewNew->Refresh();
        row = 0;

    RESCUE_CANDIDATE& selected_part = (*m_Candidates)[row];

    renderPreview( selected_part.cache_candidate, 0, m_componentViewOld );
    renderPreview( selected_part.lib_candidate, 0, m_componentViewNew );
}
}




@@ -283,7 +281,7 @@ void DIALOG_RESCUE_EACH::OnNeverShowClick( wxCommandEvent& aEvent )


    if( resp == wxID_YES )
    if( resp == wxID_YES )
    {
    {
        m_Config->Write( wxT("RescueNeverShow"), true );
        m_Config->Write( RESCUE_NEVER_SHOW_KEY, true );
        m_Candidates->clear();
        m_Candidates->clear();
        Close();
        Close();
    }
    }
+6 −6
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun  5 2014)
// http://www.wxformbuilder.org/
// http://www.wxformbuilder.org/
//
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -16,7 +16,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
	wxBoxSizer* bSizerMain;
	wxBoxSizer* bSizerMain;
	bSizerMain = new wxBoxSizer( wxVERTICAL );
	bSizerMain = new wxBoxSizer( wxVERTICAL );
	
	
	m_lblInfo = new wxStaticText( this, wxID_ANY, _("This project uses symbols that no longer match the symbols in the system libraries. Using this tool, you can rescue these cached symbols into a new library.\n\nChoose \"Rescue\" for any parts you would like to save from this project's cache, or press Cancel to allow the symbols to be updated to the new versions."), wxDefaultPosition, wxDefaultSize, 0 );
	m_lblInfo = new wxStaticText( this, wxID_ANY, _("This project uses symbols that no longer match the symbols in the system libraries.\nUsing this tool, you can rescue these cached symbols into a new library.\n\nChoose \"Rescue\" for any parts you would like to save from this project's cache, or press Cancel to allow the symbols to be updated to the new versions."), wxDefaultPosition, wxDefaultSize, 0 );
	m_lblInfo->Wrap( 500 );
	m_lblInfo->Wrap( 500 );
	bSizerMain->Add( m_lblInfo, 0, wxALL|wxEXPAND, 5 );
	bSizerMain->Add( m_lblInfo, 0, wxALL|wxEXPAND, 5 );
	
	
@@ -24,7 +24,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
	m_staticText5->Wrap( -1 );
	m_staticText5->Wrap( -1 );
	m_staticText5->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	m_staticText5->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	
	bSizerMain->Add( m_staticText5, 0, wxALL, 5 );
	bSizerMain->Add( m_staticText5, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	
	m_ListOfConflicts = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	m_ListOfConflicts = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	bSizerMain->Add( m_ListOfConflicts, 2, wxALL|wxEXPAND, 5 );
	bSizerMain->Add( m_ListOfConflicts, 2, wxALL|wxEXPAND, 5 );
@@ -33,7 +33,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
	m_staticText4->Wrap( -1 );
	m_staticText4->Wrap( -1 );
	m_staticText4->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	m_staticText4->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	
	bSizerMain->Add( m_staticText4, 0, wxALL, 5 );
	bSizerMain->Add( m_staticText4, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	
	m_ListOfInstances = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	m_ListOfInstances = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	bSizerMain->Add( m_ListOfInstances, 1, wxALL|wxEXPAND, 5 );
	bSizerMain->Add( m_ListOfInstances, 1, wxALL|wxEXPAND, 5 );
@@ -48,7 +48,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
	m_staticText2->Wrap( -1 );
	m_staticText2->Wrap( -1 );
	m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	
	bSizer6->Add( m_staticText2, 0, wxALL, 5 );
	bSizer6->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	
	m_componentViewOld = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER );
	m_componentViewOld = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER );
	m_componentViewOld->SetMinSize( wxSize( 150,150 ) );
	m_componentViewOld->SetMinSize( wxSize( 150,150 ) );
@@ -65,7 +65,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
	m_staticText3->Wrap( -1 );
	m_staticText3->Wrap( -1 );
	m_staticText3->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	m_staticText3->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	
	bSizer7->Add( m_staticText3, 0, wxALL, 5 );
	bSizer7->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	
	m_componentViewNew = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER );
	m_componentViewNew = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER );
	m_componentViewNew->SetMinSize( wxSize( 150,150 ) );
	m_componentViewNew->SetMinSize( wxSize( 150,150 ) );
+6 −6
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@
            <property name="size">529,593</property>
            <property name="size">529,593</property>
            <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
            <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
            <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
            <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
            <property name="title"></property>
            <property name="title">Conflicts Checking</property>
            <property name="tooltip"></property>
            <property name="tooltip"></property>
            <property name="window_extra_style"></property>
            <property name="window_extra_style"></property>
            <property name="window_name"></property>
            <property name="window_name"></property>
@@ -125,7 +125,7 @@
                        <property name="gripper">0</property>
                        <property name="gripper">0</property>
                        <property name="hidden">0</property>
                        <property name="hidden">0</property>
                        <property name="id">wxID_ANY</property>
                        <property name="id">wxID_ANY</property>
                        <property name="label">This project uses symbols that no longer match the symbols in the system libraries. Using this tool, you can rescue these cached symbols into a new library.&#x0A;&#x0A;Choose &quot;Rescue&quot; for any parts you would like to save from this project&apos;s cache, or press Cancel to allow the symbols to be updated to the new versions.</property>
                        <property name="label">This project uses symbols that no longer match the symbols in the system libraries.&#x0A;Using this tool, you can rescue these cached symbols into a new library.&#x0A;&#x0A;Choose &quot;Rescue&quot; for any parts you would like to save from this project&apos;s cache, or press Cancel to allow the symbols to be updated to the new versions.</property>
                        <property name="max_size"></property>
                        <property name="max_size"></property>
                        <property name="maximize_button">0</property>
                        <property name="maximize_button">0</property>
                        <property name="maximum_size"></property>
                        <property name="maximum_size"></property>
@@ -178,7 +178,7 @@
                </object>
                </object>
                <object class="sizeritem" expanded="1">
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="border">5</property>
                    <property name="flag">wxALL</property>
                    <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
                    <property name="proportion">0</property>
                    <property name="proportion">0</property>
                    <object class="wxStaticText" expanded="1">
                    <object class="wxStaticText" expanded="1">
                        <property name="BottomDockable">1</property>
                        <property name="BottomDockable">1</property>
@@ -329,7 +329,7 @@
                </object>
                </object>
                <object class="sizeritem" expanded="1">
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="border">5</property>
                    <property name="flag">wxALL</property>
                    <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
                    <property name="proportion">0</property>
                    <property name="proportion">0</property>
                    <object class="wxStaticText" expanded="1">
                    <object class="wxStaticText" expanded="1">
                        <property name="BottomDockable">1</property>
                        <property name="BottomDockable">1</property>
@@ -498,7 +498,7 @@
                                <property name="permission">none</property>
                                <property name="permission">none</property>
                                <object class="sizeritem" expanded="1">
                                <object class="sizeritem" expanded="1">
                                    <property name="border">5</property>
                                    <property name="border">5</property>
                                    <property name="flag">wxALL</property>
                                    <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
                                    <property name="proportion">0</property>
                                    <property name="proportion">0</property>
                                    <object class="wxStaticText" expanded="1">
                                    <object class="wxStaticText" expanded="1">
                                        <property name="BottomDockable">1</property>
                                        <property name="BottomDockable">1</property>
@@ -672,7 +672,7 @@
                                <property name="permission">none</property>
                                <property name="permission">none</property>
                                <object class="sizeritem" expanded="1">
                                <object class="sizeritem" expanded="1">
                                    <property name="border">5</property>
                                    <property name="border">5</property>
                                    <property name="flag">wxALL</property>
                                    <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
                                    <property name="proportion">0</property>
                                    <property name="proportion">0</property>
                                    <object class="wxStaticText" expanded="1">
                                    <object class="wxStaticText" expanded="1">
                                        <property name="BottomDockable">1</property>
                                        <property name="BottomDockable">1</property>
+2 −2
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun  5 2014)
// http://www.wxformbuilder.org/
// http://www.wxformbuilder.org/
//
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -62,7 +62,7 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM
	
	
	public:
	public:
		
		
		DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 529,593 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
		DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Conflicts Checking"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 529,593 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
		~DIALOG_RESCUE_EACH_BASE();
		~DIALOG_RESCUE_EACH_BASE();
	
	
};
};
Loading