-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor internal closure handling and several API changes #706
Refactor internal closure handling and several API changes #706
Conversation
This PR to be rebased after PR #712. |
1f7dd22
to
f687367
Compare
Hi, |
I'm actually interested in this performance drop you're talking about. Can you try and |
Already done with |
@diamondburned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thing, this will save a lot of code rewriting.
Merge conflicts addressed. |
I've fixed the branch up. |
77e9a82
to
b564fb8
Compare
@diamondburned wondering if we could add some examples to the documentation or the OP here showing how to change existing code to adapt to the changes proposed in this PR. I've got a medium sized app that will probably be affected by this, so happy to be the guinea pig and provide some feedback and code changes required for my app to compile/run again. Does that sound like a reasonable plan to you? |
Missed the updated OP that now states:
Tried to build my app against this branch and had to change a couple of lines, nothing too terrible: diff --git a/internal/ui/inprogresslist/inprogresslist.go b/internal/ui/inprogresslist/inprogresslist.go
index d05f3b4..e25a0c8 100644
--- a/internal/ui/inprogresslist/inprogresslist.go
+++ b/internal/ui/inprogresslist/inprogresslist.go
@@ -57,7 +57,7 @@ func (i *InProgressList) isShown(tree *gtk.TreeView) {
func (i *InProgressList) updateFileList() {
//TODO: use leveldb to speed things up without walking the filesystem
- i.listBox.BindModel(nil, nil, nil)
+ i.listBox.BindModel(nil, nil)
for _, doc := range downloader.Instance().DownloadsInProgress() {
i.addFileRow(doc.Name)
diff --git a/internal/ui/tagger/tagger.go b/internal/ui/tagger/tagger.go
index 025ace2..6041e4a 100644
--- a/internal/ui/tagger/tagger.go
+++ b/internal/ui/tagger/tagger.go
@@ -98,7 +98,7 @@ func (t *Tagger) removeSelected() {
func (t *Tagger) saveTags() {
var tl []tags.Tag
- t.listStore.ForEach(func(model *gtk.TreeModel, path *gtk.TreePath, iter *gtk.TreeIter, userdata ...interface{}) bool {
+ t.listStore.ForEach(func(model *gtk.TreeModel, path *gtk.TreePath, iter *gtk.TreeIter) bool {
value, _ := t.listStore.GetValue(iter, 0)
tname, _ := value.GetString()
tag := tags.Tag{Name: tname} |
Overall, most of the breaking changes are If you could point out some places where I could notify of such changes, then I'm willing to PR in some changes. Perhaps I could start with examples elsewhere... |
Good point, maybe the release notes when bumped to 0.6? perhaps @andre-hub already planned for that. |
This commit introduces proper GDestroyNotify callbacks as well as cleaner closure and callback global registries to reduce (if not eliminate) memory leaks. This commit also introduces several breaking changes. Below lists those changes in undefined order: Connect, IdleAdd, TimeoutAdd and others in GLib no longer return an error. Any error with the function argument (type interface{}) is assumed to be programmer error and will therefore panic. GLib functions in C do not have nullable returns either, so the usual nilPtrErr does not apply, therefore all error returns are omitted. All signal callbacks now also require the first argument to be the appropriate callback type to prevent cyclical references leading to memory leaks. Old Func types for callback setters no longer force a variadic list of arguments in their parameters, as Go's closure abilities allow referencing values from outside.
b564fb8
to
0ce0ad6
Compare
now! :-) |
// | ||
// This constant can be changed by using go.mod's replace directive for | ||
// debugging purposes. | ||
const ClosureCheckReceiver = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diamondburned Can you explain how to use a go.mod
replace directive to change this constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can fork the repository or clone it down, then use the replace
directive inside go.mod
, like so:
# cloned
replace github.com/gotk3/gotk3 => ../path/to/gotk3
# forked
replace github.com/gotk3/gotk3 => github.com/username/gotk3 commithash...
PrecautionI would recommend merging this PR later, perhaps when a new major (0.x for v0?)gotk3
release is planned, since these breaking changes are quite significant. Perhaps it's worth maintaining a second branch (regularly rebased withmaster
) for people to slowly migrate over.The aforementioned requirement of needing a first argument when using
Connect
has been changed to no longer requiring it, as not all scenarios require such a case, such aswin.Connect("destroy", gtk.MainQuit)
, and they do get annoying quickly over time.This pull request introduces proper
GDestroyNotify
callbacks as well as cleaner closure and callback global registries to reduce (if not eliminate) memory leaks.This pull request also introduces several breaking changes. Below lists those changes in undefined order:
interface{}
) is assumed to be programmer error and will therefore panic. GLib functions in C do not have nullable returns either, so the usualnilPtrErr
does not apply, therefore all error returns are omitted.This pull request also adds a small stack trace that occurs when any callback cannot be handled gracefully. This helps find bugs easier:
This pull request resolves #685 but might break #507.
Below lists several tidbits that were convenient for me to add during the refactor:
(*gtk.TreeView).SetSearchEqualFunc
FormatSize{,Full}
,SpacedPrimesClosest
, ...GApplication
andGDBusConnection
(low priority, can be a follow-up PR)