Hi,

this topic was already touched in Holger's "directFB and Lighthouse" mail 
but wasn't really resolved. As my concern also applies to Qt 4.8 I'd like 
to bring up this topic in a distinct mail.

Usage of the QPlatformNativeInterface class typically looks like this case 
from tst_qlistview.cpp:

  return static_cast<HWND> 
(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", 
window));

Above code is #ifdef'ed for Windows which makes it safe as there is only a 
single platform implementation available (as far as I can tell). But what 
about Linux? I count three implementations of "display" resources:

$ git grep \"display\" src/plugins/platforms/*/*.cpp
src/plugins/platforms/wayland/qwaylandnativeinterface.cpp:    if 
(lowerCaseResource == "display")
src/plugins/platforms/xcb/qxcbnativeinterface.cpp:        
insert("display",QXcbNativeInterface::Display);
src/plugins/platforms/xlib/qxlibnativeinterface.cpp:        
insert("display",QXlibNativeInterface::Display);

How will anyone be able to tell them apart without a way to check which 
plugin is active? Or has this changed?

I know, that ideally Qt should provide a portable API avoid the use of 
native resources. But realistically this will never all cases. So what to 
do? Add some runtime detection? In the case of nativeResourceForWindow() 
I'd say it would already suffice to mandate that the resource names have 
to unique. Either by a pure text prefix

   nativeResourceForWindow("xlib/display");

or a distinct parameter:

    nativeResourceForWindow("xlib", "display");

As it is I foresee weird crashes after casting void* pointers. In our 
product's code we already had to take the risk...

Harri.



_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to