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

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
......@@ -42,6 +42,7 @@
#include <wildcards_and_files_ext.h>
#include <wx/tokenzr.h>
#include <dialog_eeschema_config_fbp.h>
#include <eeschema_config.h>
class SCH_EDIT_FRAME;
......@@ -129,7 +130,7 @@ DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( wxWindow* aParent,
// Load setting for cache rescue
m_config = Kiface().KifaceSettings();
bool rescueNeverShow = false;
m_config->Read( wxT("RescueNeverShow"), &rescueNeverShow, false );
m_config->Read( RESCUE_NEVER_SHOW_KEY, &rescueNeverShow, false );
m_cbRescue->SetValue( !rescueNeverShow );
wxString msg = wxString::Format( _(
......@@ -249,7 +250,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
*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 );
}
......
......@@ -33,6 +33,7 @@
#include <vector>
#include <boost/foreach.hpp>
#include <lib_cache_rescue.h>
#include <eeschema_config.h>
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_insideUpdateEvent( false )
{
m_Config = Kiface().KifaceSettings();
}
......@@ -97,7 +99,6 @@ bool DIALOG_RESCUE_EACH::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() )
return false;
m_Config = Kiface().KifaceSettings();
m_ListOfConflicts->AppendToggleColumn( wxT("Rescue") );
m_ListOfConflicts->AppendTextColumn( wxT("Symbol Name") );
m_ListOfInstances->AppendTextColumn( wxT("Reference") );
......@@ -135,6 +136,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
m_ListOfInstances->DeleteAllItems();
int row = m_ListOfConflicts->GetSelectedRow();
if( row == wxNOT_FOUND )
row = 0;
......@@ -160,6 +162,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent )
{
int row = m_ListOfConflicts->GetSelectedRow();
if( row == wxNOT_FOUND )
row = 0;
......@@ -172,6 +175,7 @@ void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEven
void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent )
{
int row = m_ListOfConflicts->GetSelectedRow();
if( row == wxNOT_FOUND )
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
// 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 )
{
wxPaintDC dc( aPanel );
......@@ -215,9 +220,7 @@ void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel
dc.SetUserScale( scale, scale );
wxPoint offset = bBox.Centre();
NEGATE( offset.x );
NEGATE( offset.y );
wxPoint offset = - bBox.Centre();
// Avoid rendering when either dimension is zero
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.
// Make sure the correct item triggered it, otherwise we trigger recursively
// and get a stack overflow.
if( aEvent.GetEventObject() != m_ListOfConflicts ) return;
if( aEvent.GetEventObject() != m_ListOfConflicts )
return;
PopulateInstanceList();
int row = m_ListOfConflicts->GetSelectedRow();
if( row == wxNOT_FOUND )
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 );
m_componentViewOld->Refresh();
m_componentViewNew->Refresh();
}
......@@ -283,7 +281,7 @@ void DIALOG_RESCUE_EACH::OnNeverShowClick( wxCommandEvent& aEvent )
if( resp == wxID_YES )
{
m_Config->Write( wxT("RescueNeverShow"), true );
m_Config->Write( RESCUE_NEVER_SHOW_KEY, true );
m_Candidates->clear();
Close();
}
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -16,7 +16,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerMain;
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 );
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->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 );
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->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 );
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->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->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->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->SetMinSize( wxSize( 150,150 ) );
......
......@@ -47,7 +47,7 @@
<property name="size">529,593</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</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="window_extra_style"></property>
<property name="window_name"></property>
......@@ -125,7 +125,7 @@
<property name="gripper">0</property>
<property name="hidden">0</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="maximize_button">0</property>
<property name="maximum_size"></property>
......@@ -178,7 +178,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
......@@ -329,7 +329,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
......@@ -498,7 +498,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
......@@ -672,7 +672,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -62,7 +62,7 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM
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();
};
......
......@@ -48,7 +48,9 @@ private:
DIALOG_RESCUE_SUMMARY::DIALOG_RESCUE_SUMMARY( SCH_EDIT_FRAME* aParent, std::vector<RESCUE_LOG>& aRescueLog )
: DIALOG_RESCUE_SUMMARY_BASE( aParent ), m_Parent( aParent), m_RescueLog( &aRescueLog )
{ }
{
m_Config = Kiface().KifaceSettings();
}
bool DIALOG_RESCUE_SUMMARY::TransferDataToWindow()
......@@ -56,7 +58,6 @@ bool DIALOG_RESCUE_SUMMARY::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() )
return false;
m_Config = Kiface().KifaceSettings();
m_ListOfChanges->AppendTextColumn( wxT( "Reference" ) );
m_ListOfChanges->AppendTextColumn( wxT( "Old Symbol" ), wxDATAVIEW_CELL_INERT, /*width*/ 100);
m_ListOfChanges->AppendTextColumn( wxT( "New Symbol" ), wxDATAVIEW_CELL_INERT, /*width*/ 100);
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -21,17 +21,19 @@ DIALOG_RESCUE_SUMMARY_BASE::DIALOG_RESCUE_SUMMARY_BASE( wxWindow* parent, wxWind
m_staticText5 = new wxStaticText( this, wxID_ANY, _("The symbols of the following components were changed:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bupperSizer->Add( m_staticText5, 0, wxALL, 5 );
bupperSizer->Add( m_staticText5, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ListOfChanges = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_ListOfChanges->SetMinSize( wxSize( -1,200 ) );
bupperSizer->Add( m_ListOfChanges, 1, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1->Realize();
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizer->Realize();
bupperSizer->Add( m_sdbSizer1, 0, wxEXPAND, 5 );
bupperSizer->Add( m_sdbSizer, 0, wxEXPAND, 5 );
bmainSizer->Add( bupperSizer, 1, wxALL|wxEXPAND, 6 );
......
......@@ -104,7 +104,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
......@@ -199,7 +199,7 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="minimum_size">-1,200</property>
<property name="name">m_ListOfChanges</property>
<property name="permission">protected</property>
<property name="pos"></property>
......@@ -267,7 +267,7 @@
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -38,8 +38,8 @@ class DIALOG_RESCUE_SUMMARY_BASE : public DIALOG_SHIM
protected:
wxStaticText* m_staticText5;
wxDataViewListCtrl* m_ListOfChanges;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
public:
......
......@@ -2,4 +2,12 @@
* @file eeschema_config.h
*/
#ifndef EESCHEMA_CONFIG_H
#define EESCHEMA_CONFIG_H
#include <config_params.h>
// a key to read write in user config the visibility of the rescue library dialog
#define RESCUE_NEVER_SHOW_KEY wxT("RescueNeverShow")
#endif // EESCHEMA_CONFIG_H
......@@ -44,6 +44,7 @@
#include <sch_component.h>
#include <wildcards_and_files_ext.h>
#include <lib_cache_rescue.h>
#include <eeschema_config.h>
bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bool aCreateBackupFile )
......@@ -310,7 +311,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// Only do this if RescueNeverShow was not set.
wxConfigBase *config = Kiface().KifaceSettings();
bool rescueNeverShow = false;
config->Read( wxT("RescueNeverShow"), &rescueNeverShow, false );
config->Read( RESCUE_NEVER_SHOW_KEY, &rescueNeverShow, false );
if( !rescueNeverShow )
{
if( RescueCacheConflicts( false ) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment