Comments (4)
@Rightbputnow1 Another way to completely sidestep those issues is to transform the message classes into reference counted objects, much like QString and QByteArray #180
from qtprotobuf.
@Rightbputnow1 could you please provide the minimum example when this happens. In common cases you don't need to set an explicit value ownership when accessing the property. But of course there are exceptions, e.g. when the value is returned from the function. Also it's not clear to me what corrupts the shared pointer ref counter.
from qtprotobuf.
Say you have the following sample message:
syntax="proto3";
package Crash;
message Sample {
repeated Agregate agregate = 1;
}
message Agregate {
uint64 sample = 1;
}
Now agregate is generated as QList<QSharedPointer>
Accessing any QSharedPointer's data in the previous list from Qml trough a Q_INVOKABLE would blindside the QSharedPointer atomic ref count as the QML JS engine would take ownership of the data and destroy it as soon as the Q_INVOKABLE call return since its note referenced by any javascript named id. The QSharedPointer is now left with a floating data although indicating otherwise and would cause any further dereferencing of the QSharedPointer data to randomly crash the app (garbage collector behavior is not predictible, may instantly crash giving insight on the source of the crash, may crash further in the app's lifetime leaving the user clueless which happened to my colleagues :').
Best fix would be to implement a QML friendly cpp ownership enforcing QSharedPointer that does not hang its data to dry once accessed from the QML.
Quickest fix has been proposed as a pull request, basically adding the cpp ownership setter in the message generation portion of code of the message generator.
from qtprotobuf.
from qtprotobuf.
Related Issues (20)
- Optional fields not supported HOT 6
- -Wall -Werror makes qtprotobuf depend on exact compiler and version
- Building with Qt 6 HOT 5
- How to use qtprotobuf 0.6.0 Windows release HOT 3
- "Container is less than required fields number. Deserialization failed" error HOT 1
- Nested messages and handling HOT 2
- repeated enum is not accessible from QML HOT 3
- Support enum field for Oneof HOT 1
- Build fail with Qt 5.15.2 at linux HOT 1
- simplechat client requires restart after authentication failure HOT 1
- Shared Lib option does not work for MSVC build HOT 3
- Qt module nstall does not work HOT 1
- Proto compiler does not work (MSVC Build) HOT 3
- Unnecessary Logs in Application Output HOT 1
- Cmake build examples : Trying to enable QML support for 'any', but Qt::Qml is not a target HOT 2
- error: specialization of ‘template in different namespace in qprotobufserializer.cpp HOT 2
- Build errors when cross compiling HOT 1
- Build errors HOT 1
- Make message generation configurable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qtprotobuf.