Move env var substitution into GetAssociatedDocument
We always want the documents to have their variables replaced when
opening the associated file.
Fixes: lp:1819309
* https://bugs.launchpad.net/kicad/+bug/1819309
(cherry picked from commit 9bfce26ce7
)
This commit is contained in:
parent
73664e610b
commit
de22148b44
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -103,18 +103,19 @@ bool GetAssociatedDocument( wxWindow* aParent,
|
||||||
wxT( "file:" )
|
wxT( "file:" )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Replace before resolving as we might have a URL in a variable
|
||||||
|
docname = ResolveUriByEnvVars( aDocName );
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < arrayDim(url_header); ii++ )
|
for( unsigned ii = 0; ii < arrayDim(url_header); ii++ )
|
||||||
{
|
{
|
||||||
if( aDocName.First( url_header[ii] ) == 0 ) // looks like an internet url
|
if( docname.First( url_header[ii] ) == 0 ) // looks like an internet url
|
||||||
{
|
{
|
||||||
wxURI uri( aDocName );
|
wxURI uri( docname );
|
||||||
wxLaunchDefaultBrowser( uri.BuildURI() );
|
wxLaunchDefaultBrowser( uri.BuildURI() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
docname = aDocName;
|
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
|
docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
|
||||||
#else
|
#else
|
||||||
|
@ -123,17 +124,17 @@ bool GetAssociatedDocument( wxWindow* aParent,
|
||||||
|
|
||||||
|
|
||||||
/* Compute the full file name */
|
/* Compute the full file name */
|
||||||
if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
|
if( wxIsAbsolutePath( docname ) || aPaths == NULL)
|
||||||
fullfilename = aDocName;
|
fullfilename = docname;
|
||||||
/* If the file exists, this is a trivial case: return the filename
|
/* If the file exists, this is a trivial case: return the filename
|
||||||
* "as this". the name can be an absolute path, or a relative path
|
* "as this". the name can be an absolute path, or a relative path
|
||||||
* like ./filename or ../<filename>
|
* like ./filename or ../<filename>
|
||||||
*/
|
*/
|
||||||
else if( wxFileName::FileExists( aDocName ) )
|
else if( wxFileName::FileExists( docname ) )
|
||||||
fullfilename = aDocName;
|
fullfilename = docname;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fullfilename = aPaths->FindValidPath( aDocName );
|
fullfilename = aPaths->FindValidPath( docname );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString mask( wxT( "*" ) ), extension;
|
wxString mask( wxT( "*" ) ), extension;
|
||||||
|
@ -160,7 +161,7 @@ bool GetAssociatedDocument( wxWindow* aParent,
|
||||||
|
|
||||||
if( !wxFileExists( fullfilename ) )
|
if( !wxFileExists( fullfilename ) )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Doc File \"%s\" not found" ), GetChars( aDocName ) );
|
msg.Printf( _( "Doc File \"%s\" not found" ), GetChars( docname ) );
|
||||||
DisplayError( aParent, msg );
|
DisplayError( aParent, msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,10 +279,7 @@ protected:
|
||||||
wxString filename = GetValue();
|
wxString filename = GetValue();
|
||||||
|
|
||||||
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
||||||
{
|
GetAssociatedDocument( m_dlg, GetValue() );
|
||||||
wxString uri = ResolveUriByEnvVars( GetValue() );
|
|
||||||
GetAssociatedDocument( m_dlg, uri );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_SHIM* m_dlg;
|
DIALOG_SHIM* m_dlg;
|
||||||
|
|
|
@ -95,7 +95,6 @@ protected:
|
||||||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||||
{
|
{
|
||||||
wxString datasheet_uri = m_grid->GetCellValue( m_grid->GetGridCursorRow(), DATASHEET );
|
wxString datasheet_uri = m_grid->GetCellValue( m_grid->GetGridCursorRow(), DATASHEET );
|
||||||
datasheet_uri = ResolveUriByEnvVars( datasheet_uri );
|
|
||||||
GetAssociatedDocument( m_dlg, datasheet_uri );
|
GetAssociatedDocument( m_dlg, datasheet_uri );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -522,7 +522,6 @@ void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
|
||||||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||||
{
|
{
|
||||||
wxString datasheet_uri = m_grid->GetCellValue( DATASHEET, FDC_VALUE );
|
wxString datasheet_uri = m_grid->GetCellValue( DATASHEET, FDC_VALUE );
|
||||||
datasheet_uri = ResolveUriByEnvVars( datasheet_uri );
|
|
||||||
GetAssociatedDocument( m_dlg, datasheet_uri );
|
GetAssociatedDocument( m_dlg, datasheet_uri );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -617,8 +617,6 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
||||||
else
|
else
|
||||||
filename = part->GetAlias( 0 )->GetDocFileName();
|
filename = part->GetAlias( 0 )->GetDocFileName();
|
||||||
|
|
||||||
filename = ResolveUriByEnvVars( filename );
|
|
||||||
|
|
||||||
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
||||||
{
|
{
|
||||||
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
||||||
|
|
|
@ -1033,7 +1033,6 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||||
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
||||||
{
|
{
|
||||||
wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
|
wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
|
||||||
text = ResolveUriByEnvVars( text );
|
|
||||||
|
|
||||||
if( !text.IsEmpty() )
|
if( !text.IsEmpty() )
|
||||||
GetAssociatedDocument( this, text );
|
GetAssociatedDocument( this, text );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2014 Jerry Jacobs
|
* Copyright (C) 2009-2014 Jerry Jacobs
|
||||||
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
* Copyright (C) 1992-2019 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -42,7 +42,8 @@ bool KeywordMatch( const wxString& aKeys, const wxString& aDatabase );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetAssociatedDocument
|
* Function GetAssociatedDocument
|
||||||
* open a document (file) with the suitable browser
|
* open a document (file) with the suitable browser. Environmental variables are
|
||||||
|
* substituted before the document name is resolved for either browser or file
|
||||||
* @param aParent = main frame
|
* @param aParent = main frame
|
||||||
* @param aDocName = filename of file to open (Full filename or short filename)
|
* @param aDocName = filename of file to open (Full filename or short filename)
|
||||||
* if \a aDocName begins with http: or ftp: or www. the default internet browser is launched
|
* if \a aDocName begins with http: or ftp: or www. the default internet browser is launched
|
||||||
|
|
Loading…
Reference in New Issue