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

added 'unload_zbarcam' that unload zbarcam.kv and xcamera.kv files #81

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

qlrd
Copy link

@qlrd qlrd commented Oct 29, 2023

This PR add a unload_zbarcam method.

This method fixes the issue "restart after releasing the camera results in these warnings followed by pages of errors"

The solution was to unload zbarcam.kv and xcamera.kv files (see this response).

A working example with this approach can be found here.

@@ -210,3 +211,19 @@ def stop(self):
self.xcamera.play = False
if platform == "android":
self.xcamera._camera._release_camera()

def unload_zbarcam(self):
id ZBarCam.kv_loaded:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean if?
Pity we no longer have working tests for this repo, this would have been caught easily

Copy link
Author

Choose a reason for hiding this comment

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

Yes, sorry for typo.

I will fix this and create a new commit

Copy link
Author

Choose a reason for hiding this comment

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

Pity we no longer have working tests for this repo, this would have been caught easily

Maybe I can work with some github-action to do this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah we would love to 👍

Fixed typo: `id` to `if` on `unload_zbarcam method
Copy link
Collaborator

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

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

Thanks for the update.
I tried to find where that approach is used in the code you linked, but I didn't find it as in b68fe7b I GitHub searched for unload_file, but got no results.
I would it make sense to call this method as we call the stop method?

@qlrd
Copy link
Author

qlrd commented Oct 30, 2023

I tried to find where that approach is used in the code you linked

Sorry again 😭

Didn't add this as unload_zbarcam or unload_file. I only hardcoded it.

I would it make sense to call this method as we call the stop method?

I think it make sense, since the stop method dint unload .kv files and if someone want to reload zbarcam, the App can crash (like what happened with me). I would like to point 3 things:

  1. Maybe call unload_files since it unload either zbarcam.kv and xcamera.kv? Or will this bring more confusion? (maybe call it simply unload?)
  2. Maybe make it as a "protected" method _unload and call it on stop method?
  3. I did not tested on android; maybe there might be some strange behavior for smartphones using this?

I will wait for response before make any new commit

@AndreMiras
Copy link
Collaborator

Yes for 1 & 2 _unload(), let's go for it.
Good to know that you didn't get a chance to test on Android. I'd like to make sure it doesn't introduce regressions on Android indeed.

added release device step for non android devices in  method

changed  method to
@qlrd
Copy link
Author

qlrd commented Oct 30, 2023

Yes for 1 & 2 _unload(), let's go for it. Good to know that you didn't get a chance to test on Android. I'd like to make sure it doesn't introduce regressions on Android indeed.

Done.

I added a step for releasing devices on non android devices in stop method.

Sorry for "incomplete" commit message. It was suposed to be:

updated zbarcam.py
added release device step for non android devices in stop method
changed _unload_zbarcam method to _unload

@qlrd
Copy link
Author

qlrd commented Nov 7, 2023

@AndreMiras, did you tested the code?

@AndreMiras
Copy link
Collaborator

I didn't get a chance to. Do you mind giving it a try?

@qlrd
Copy link
Author

qlrd commented Nov 9, 2023

I didn't get a chance to. Do you mind giving it a try?

I can try, but i need some time to apply

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.

2 participants