Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/common/helpers.py
    ... ... @@ -1280,7 +1280,8 @@ def write_file_async(
    1280 1280
             user_data: Optional[Any] = None):
    
    1281 1281
     
    
    1282 1282
         def _on_write_finished(outputstream: Gio.OutputStream,
    
    1283
    -                           result: Gio.AsyncResult) -> None:
    
    1283
    +                           result: Gio.AsyncResult,
    
    1284
    +                           _data: bytes) -> None:
    
    1284 1285
             try:
    
    1285 1286
                 successful, _bytes_written = outputstream.write_all_finish(result)
    
    1286 1287
             except GLib.Error as error:
    
    ... ... @@ -1295,10 +1296,14 @@ def _on_file_created(file: Gio.File, result: Gio.AsyncResult) -> None:
    1295 1296
                 callback(False, error, user_data)
    
    1296 1297
                 return
    
    1297 1298
     
    
    1299
    +        # Pass data as user_data to the callback, because
    
    1300
    +        # write_all_async() takes no reference to the data
    
    1301
    +        # and python gc collects it before the data is written
    
    1298 1302
             outputstream.write_all_async(data,
    
    1299 1303
                                          GLib.PRIORITY_DEFAULT,
    
    1300 1304
                                          None,
    
    1301
    -                                     _on_write_finished)
    
    1305
    +                                     _on_write_finished,
    
    1306
    +                                     data)
    
    1302 1307
     
    
    1303 1308
         file = Gio.File.new_for_path(str(path))
    
    1304 1309
         file.create_async(Gio.FileCreateFlags.PRIVATE,