Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
4.8.1, 4.8.3, 4.8.4
-
None
-
QNX with QWS
Description
Attaching to qnx surfaces has an incorrect approach in qscreenqnx_qws.cpp in static inline bool createMemSurface(QQnxScreenContext * const d, int w, int h).
#ifndef QT_NO_QWS_MULTIPROCESS
if (QApplication::type() != QApplication::GuiServer) {
unsigned sidlist[64];
int n = gf_surface_sidlist(d->device, sidlist); // undocumented API
for (int i = 0; i < n; ++i) {
int ret = gf_surface_attach_by_sid(&d->memSurface, d->device, sidlist[i]);
if (ret == GF_ERR_OK) {
gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
if (d->memSurfaceInfo.sid != unsigned(GF_SID_INVALID)) {
// can we use the surface's vaddr?
unsigned flags = GF_SURFACE_CPU_LINEAR_READABLE | GF_SURFACE_CPU_LINEAR_WRITEABLE;
if ((d->memSurfaceInfo.flags & flags) == flags)
return true;
}
gf_surface_free(d->memSurface);
d->memSurface = 0;
}
}
qWarning("QQnxScreen: cannot attach to an usable surface; create a new one.");
}
#endif
It can't just enumerate available surfaces and attach to any available. That's because the video driver itself may create surfaces for its internal needs (e.g. i830 creates a black filled surface to emulate screen turned off).
One solution would be to have a named shared memory region and track reference count for Qt applications using the surface there. That means that the first application that starts must create a new surface and save it's sid with refcount of 1 into shared memory. And then the subsequent appplications would just pick sid value from shared memory, increment reference count for it and attach to existing surface. Similarly, the reference count is decremented when applications exit and surface can be deleted when last application closes.