Skip to content
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

Handlers & DBus (gif, clock & counter as examples) #2

Merged
merged 8 commits into from
Aug 19, 2020

Conversation

The-Jonsey
Copy link
Member

No description provided.

@The-Jonsey The-Jonsey requested a review from okratitan July 30, 2020 15:44
@The-Jonsey The-Jonsey changed the title Handlers (gif, clock & counter as examples) Handlers & DBus (gif, clock & counter as examples) Aug 11, 2020
handler.go Outdated
)

type IconHandler interface {
Icon(page int, index int, key *Key, dev streamdeck.Device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reading this through again I realised that this name confused me. It's a noun which implies a getter but there is no return . What should an icon handler do? perhaps it needs a doc, or a more descriptive name?

The same may be true of "Key" below as well, except that could be read as a verb I guess.

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 instances of panic (either panic or log.Panic -one is on the dbus init which kind of makes sense.
The others are in image load, key update etc, but there are no recover clauses - so if the GUI sets the config to an invalid image or a key handler fails this daemon will quit. Seems like a bad idea

@andydotxyz
Copy link
Contributor

The following diff fixes a crash on first time launch.
I have not added as a commit as there is disagreement as to whether instead a blank file should be written:

index dfac0e1..1ec2686 100644
--- a/interface.go
+++ b/interface.go
@@ -67,11 +67,10 @@ func SetKey(currentKey *Key, i int) {
 func SetPage(config *Config, page int, dev streamdeck.Device) {
        p = page
        currentPage := config.Pages[page]
-       for i := 0; i < 15; i++ {
-               currentKey := &currentPage[i]
+       for i, currentKey := range currentPage {
                if currentKey.Buff == nil {
                        if currentKey.IconHandler == "" {
-                               SetKey(currentKey, i)
+                               SetKey(&currentKey, i)
 
                        } else if currentKey.IconHandlerStruct == nil {
                                var handler IconHandler
@@ -85,7 +84,7 @@ func SetPage(config *Config, page int, dev streamdeck.Device) {
                                if handler == nil {
                                        continue
                                }
-                               handler.Icon(page, i, currentKey, dev)
+                               handler.Icon(page, i, &currentKey, dev)
                                currentKey.IconHandlerStruct = handler
                        }
                } else {
diff --git a/main.go b/main.go
index 5c4a68d..80e84e3 100644
--- a/main.go
+++ b/main.go
@@ -38,7 +38,9 @@ func main() {
                config.Pages = append(config.Pages, Page{})
        }
        cleanupHook()
-       SetPage(config, 0, dev)
+       if len(config.Pages) > 0 {
+               SetPage(config, 0, dev)
+       }
        go InitDBUS()
        Listen()
 }
~

@The-Jonsey The-Jonsey requested a review from andydotxyz August 18, 2020 18:09
Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With modules on compile fails - the version of API is out of date

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with the reservation that I think the handler API should be improved.
If that is someone else's work in a new PR then merge away

@The-Jonsey The-Jonsey merged commit 1031ba4 into master Aug 19, 2020
The-Jonsey added a commit that referenced this pull request Dec 27, 2021
Handlers & DBus (gif, clock & counter as examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants