@@ -151,8 +151,8 @@ def txtLine_changed(self, txtWidget):
151
151
152
152
def display_svg (self ):
153
153
# Create a temp file for this thumbnail image
154
- new_file , tmp_filename = tempfile .mkstemp ()
155
- tmp_filename = "%s.png" % tmp_filename
154
+ new_file , tmp_filename = tempfile .mkstemp (suffix = ".png" )
155
+ os . close ( new_file )
156
156
157
157
# Create a clip object and get the reader
158
158
clip = openshot .Clip (self .filename )
@@ -161,7 +161,7 @@ def display_svg(self):
161
161
# Open reader
162
162
reader .Open ()
163
163
164
- # Save thumbnail image and close readers
164
+ # Overwrite temp file with thumbnail image and close readers
165
165
reader .GetFrame (1 ).Thumbnail (
166
166
tmp_filename ,
167
167
self .graphicsView .width (),
@@ -170,15 +170,23 @@ def display_svg(self):
170
170
reader .Close ()
171
171
clip .Close ()
172
172
173
+ # Attempt to load saved thumbnail
174
+ svg = QtGui .QPixmap ()
175
+ if not svg .load (tmp_filename ):
176
+ log .error ("Couldn't load title preview from {}" .format (tmp_filename ))
177
+ return
178
+
173
179
# Display temp image
174
180
scene = QGraphicsScene (self )
175
181
view = self .graphicsView
176
- svg = QtGui .QPixmap (tmp_filename )
177
182
svg_scaled = svg .scaled (self .graphicsView .size (), Qt .KeepAspectRatio , Qt .SmoothTransformation )
178
183
scene .addPixmap (svg_scaled )
179
184
view .setScene (scene )
180
185
view .show ()
181
186
187
+ # Remove temporary file
188
+ os .unlink (tmp_filename )
189
+
182
190
def create_temp_title (self , template_path ):
183
191
184
192
# Set temp file path
0 commit comments