Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Bronko
gajim
Commits
c3485caf
Commit
c3485caf
authored
Dec 29, 2019
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass data to the callback when calling write_all_async()
- Fix indentation
parent
587cec9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
gajim/common/helpers.py
gajim/common/helpers.py
+9
-7
No files found.
gajim/common/helpers.py
View file @
c3485caf
...
...
@@ -1745,10 +1745,10 @@ class Observable:
def
write_file_async
(
path
,
data
,
callback
,
user_data
=
None
):
file
=
Gio
.
File
.
new_for_path
(
str
(
path
))
file
.
create_async
(
Gio
.
FileCreateFlags
.
PRIVATE
,
GLib
.
PRIORITY_DEFAULT
,
None
,
_on_file_created
,
(
callback
,
data
,
user_data
))
GLib
.
PRIORITY_DEFAULT
,
None
,
_on_file_created
,
(
callback
,
data
,
user_data
))
def
_on_file_created
(
file
,
result
,
user_data
):
callback
,
data
,
user_data
=
user_data
...
...
@@ -1756,16 +1756,18 @@ def _on_file_created(file, result, user_data):
outputstream
=
file
.
create_finish
(
result
)
except
GLib
.
Error
as
error
:
callback
(
False
,
error
,
user_data
)
return
# Pass data as user_data to the callback, because
# write_all_async() takes not reference to the data
# and python gc collects it before the data are written
outputstream
.
write_all_async
(
data
,
GLib
.
PRIORITY_DEFAULT
,
None
,
_on_write_finished
,
(
callback
,
user_data
))
(
callback
,
data
,
user_data
))
def
_on_write_finished
(
outputstream
,
result
,
user_data
):
callback
,
user_data
=
user_data
callback
,
_data
,
user_data
=
user_data
try
:
successful
,
_bytes_written
=
outputstream
.
write_all_finish
(
result
)
except
GLib
.
Error
as
error
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment