Discussion:
Failing to store data on mobile
Miika Turkia
2018-10-29 04:40:58 UTC
Permalink
I have tried to implement copy-paste functionality for the
Subsurface-mobile. The current branch (mobile-copy) seems to be working but
when re-opening Subsurface, nothing has been saved. So what is the trick to
actually save data when using QML? So far, I have tried to mark the
divelist changed and manually save to cloud, and what not, but am I
manipulating wrong data or what, as nothing seems to actually save what I
have changed?

miika
Dirk Hohndel
2018-10-29 14:34:05 UTC
Permalink
I have tried to implement copy-paste functionality for the Subsurface-mobile. The current branch (mobile-copy) seems to be working but when re-opening Subsurface, nothing has been saved. So what is the trick to actually save data when using QML? So far, I have tried to mark the divelist changed and manually save to cloud, and what not, but am I manipulating wrong data or what, as nothing seems to actually save what I have changed?
Call QMLManager::changesNeedSaving()
The problem is that right now on Android we only save the changes locally and the logic that we had in place to save them to the cloud when the app switches to the background may no longer be working.
But at least this function should get them saved to the local git repo

/D
Miika Turkia
2018-10-29 15:17:35 UTC
Permalink
Post by Miika Turkia
Post by Miika Turkia
I have tried to implement copy-paste functionality for the
Subsurface-mobile. The current branch (mobile-copy) seems to be working but
when re-opening Subsurface, nothing has been saved. So what is the trick to
actually save data when using QML? So far, I have tried to mark the
divelist changed and manually save to cloud, and what not, but am I
manipulating wrong data or what, as nothing seems to actually save what I
have changed?
Call QMLManager::changesNeedSaving()
The problem is that right now on Android we only save the changes locally
and the logic that we had in place to save them to the cloud when the app
switches to the background may no longer be working.
But at least this function should get them saved to the local git repo
I am calling that, but still nothing gets saved. Not locally and not on
cloud.

miika
Dirk Hohndel
2018-10-29 15:32:47 UTC
Permalink
Post by Dirk Hohndel
I have tried to implement copy-paste functionality for the Subsurface-mobile. The current branch (mobile-copy) seems to be working but when re-opening Subsurface, nothing has been saved. So what is the trick to actually save data when using QML? So far, I have tried to mark the divelist changed and manually save to cloud, and what not, but am I manipulating wrong data or what, as nothing seems to actually save what I have changed?
Call QMLManager::changesNeedSaving()
The problem is that right now on Android we only save the changes locally and the logic that we had in place to save them to the cloud when the app switches to the background may no longer be working.
But at least this function should get them saved to the local git repo
I am calling that, but still nothing gets saved. Not locally and not on cloud.
That's strange, because that function calls mark_divelist_changed(true) - so anything that is in the divelist should be saved to the local repo.

After you call that function, what is added to your log?
asked to save changes but no unsaved changes
or
save operation in progress already
would explain why nothing gets saved.
Otherwise you should get a "Save changes to local cache".
And then there are a bunch more possible reasons why it wouldn't update things - look at the awkwardly named "loadDivesWithValidCredentials()" function (which is, in fact, where we save things...)

/D
Linus Torvalds
2018-10-29 15:51:00 UTC
Permalink
Post by Dirk Hohndel
That's strange, because that function calls mark_divelist_changed(true) - so anything that is in the divelist should be saved to the local repo.
Anything that changes a dive also needs to call
'invalidate_dive_cache()' for it to be saved - otherwise we'll just
reuse the git object.

Might that be the issue?

Linus
Miika Turkia
2018-10-29 15:54:22 UTC
Permalink
Post by Dirk Hohndel
Post by Miika Turkia
Post by Miika Turkia
I have tried to implement copy-paste functionality for the
Subsurface-mobile. The current branch (mobile-copy) seems to be working but
when re-opening Subsurface, nothing has been saved. So what is the trick to
actually save data when using QML? So far, I have tried to mark the
divelist changed and manually save to cloud, and what not, but am I
manipulating wrong data or what, as nothing seems to actually save what I
have changed?
Call QMLManager::changesNeedSaving()
The problem is that right now on Android we only save the changes locally
and the logic that we had in place to save them to the cloud when the app
switches to the background may no longer be working.
But at least this function should get them saved to the local git repo
I am calling that, but still nothing gets saved. Not locally and not on cloud.
That's strange, because that function calls mark_divelist_changed(true) -
so anything that is in the divelist should be saved to the local repo.
After you call that function, what is added to your log?
asked to save changes but no unsaved changes
or
save operation in progress already
would explain why nothing gets saved.
Otherwise you should get a "Save changes to local cache".
And then there are a bunch more possible reasons why it wouldn't update
things - look at the awkwardly named "loadDivesWithValidCredentials()"
function (which is, in fact, where we save things...)
Log seems like everything gets saved:
---8<---
INFO: "14.123: Save changes to local cache"
INFO: "14.127: Synchronising data file"
INFO: "14.128: Preparing to save data"
INFO: "14.129: Start saving data"
INFO: "14.130: Start saving dives"
INFO: "14.132: Done creating local cache"
---8<---

Anyway, it seems to be that Linus' hint of calling invalidate_dive_cache()
did the trick.

tnx
miika
Dirk Hohndel
2018-10-29 16:26:49 UTC
Permalink
Anyway, it seems to be that Linus' hint of calling invalidate_dive_cache() did the trick.
Which begs the question if this should be added somewhere in that call chain in the first place...

/D

Loading...