diff --git a/website/docs/development/wrapper_caching.md b/website/docs/development/wrapper_caching.md index b7ba9aa7c..30a98da9b 100644 --- a/website/docs/development/wrapper_caching.md +++ b/website/docs/development/wrapper_caching.md @@ -23,3 +23,8 @@ A related use case is where we want to "recycle" wrappers and ensure that for a Another goal of this use case is to ensure that the unexpected destruction of the underlying QObject is handled in a more graceful and helpful way than just segfaulting the whole application. This requires the tracking of the QObject via its "destroy" signal and using that to communicate back to JS what has happened. +The object creation sequence runs quite differently than in the "Wrapper Keep Alive" case because the application initiates the creation of the object and NodeGui then creates the different wrappers on the JS and C++ sides. + +![Wrapper recycle sequence diagram](wrapper_recycle_seq.png) + +The destruction sequence in the case of the C++ object being destroyed is basically the same as the "Wrapper Keep Alive" case. \ No newline at end of file diff --git a/website/docs/development/wrapper_keep_alive_seq.png b/website/docs/development/wrapper_keep_alive_seq.png index 0bbc0adf4..b39fa1600 100644 Binary files a/website/docs/development/wrapper_keep_alive_seq.png and b/website/docs/development/wrapper_keep_alive_seq.png differ diff --git a/website/docs/development/wrapper_keep_alive_seq.puml b/website/docs/development/wrapper_keep_alive_seq.puml index 39175b332..e0711b941 100644 --- a/website/docs/development/wrapper_keep_alive_seq.puml +++ b/website/docs/development/wrapper_keep_alive_seq.puml @@ -34,6 +34,9 @@ qwindowts --> qwindowwrap: screen() qwindowwrap --> qwindow: screen() qwindow --> qwindowwrap: QScreen instance qwindowwrap --> wrappercachecpp: get() +note over wrappercachecpp + Checks wrapper cache +end note wrappercachecpp --> qscreenwrap: new() activate qscreenwrap qscreenwrap --> wrappercachecpp: QScreenWrap instance diff --git a/website/docs/development/wrapper_recycle_seq.png b/website/docs/development/wrapper_recycle_seq.png new file mode 100644 index 000000000..fbf26d5a3 Binary files /dev/null and b/website/docs/development/wrapper_recycle_seq.png differ diff --git a/website/docs/development/wrapper_recycle_seq.puml b/website/docs/development/wrapper_recycle_seq.puml new file mode 100644 index 000000000..8f789468e --- /dev/null +++ b/website/docs/development/wrapper_recycle_seq.puml @@ -0,0 +1,46 @@ +@startuml + +skinparam object { + backgroundColor White + borderColor Black + arrowColor Black +} + +skinparam note { + backgroundColor LightYellow + borderColor Black +} + +hide footbox + +title Wrapper Recycle + +participant App as app << ts >> #E3C800 +participant "QObject.ts" as qobjectts << ts>> #E3C800 + +participant "WrapperCache" as wrappercachets << ts>> #E3C800 +participant "QObjectWrap" as qobjectwrap << cpp >> +participant "WrapperCache" as wrappercachecpp << cpp >> +participant "QObject" as qobject << cpp >> #D5E8D4 + +== Wrapper construction == + +app --> qobjectts: new() +activate qobjectts +qobjectts --> qobjectwrap: new() +activate qobjectwrap +qobjectwrap --> qobject: new() +activate qobject +qobject --> qobjectwrap: QObject instance + +qobjectwrap --> wrappercachecpp: store(QObject, QObjectWrap) +wrappercachecpp --> qobject: connect to destroy signal + +qobjectwrap --> qobjectts: QOjectWrap instance +qobjectts --> wrappercachets: store(QObject.ts) +qobjectts --> app: QObject instance + + +note across: The app can use the QObject and run. + +@enduml