From a8ade66fb634612771046c4d5fcc92eccffb93e6 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <seth@kipro-pcb.com>
Date: Tue, 25 Aug 2020 12:32:26 -0700
Subject: [PATCH] 3d: correct expanded model location

When expanding WRZ, make sure we are reading the new file and that it
has been created in the user's temporary directory.

Fixes https://gitlab.com/kicad/code/kicad/issues/5360
---
 plugins/3d/vrml/vrml.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/plugins/3d/vrml/vrml.cpp b/plugins/3d/vrml/vrml.cpp
index 768f0edcf7..d339a1539a 100644
--- a/plugins/3d/vrml/vrml.cpp
+++ b/plugins/3d/vrml/vrml.cpp
@@ -169,6 +169,8 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
     {
         wxFileInputStream ifile( aFileName );
         tmpfilename = wxFileName( aFileName );
+
+        tmpfilename.SetPath( wxStandardPaths::Get().GetTempDir() );
         tmpfilename.SetExt( "WRL" );
 
         wxFileOffset size = ifile.GetLength();
@@ -200,7 +202,7 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
     {
         // set the max char limit to 8MB; if a VRML file contains
         // longer lines then perhaps it shouldn't be used
-        modelFile = new FILE_LINE_READER( aFileName, 0, 8388608 );
+        modelFile = new FILE_LINE_READER( filename, 0, 8388608 );
     }
     catch( IO_ERROR & )
     {