Review Request 118016: Fix wrong constructor resolution

Marco Martin notmart at gmail.com
Tue May 6 14:34:48 UTC 2014



> On May 6, 2014, 1:30 p.m., Kevin Ottens wrote:
> > AFAICT it is BIC but no SIC, no brainer.
> 
> Martin Gräßlin wrote:
>     it's a SIC change as one could have used the variant specifying just NET::Properties and screen. This would now have to be changed to use NET::Properties2 before screen argument.
> 
> Thomas Lübking wrote:
>     It's SIC.
>     "NETRootInfo(connection, properties, 1);" would now cause an error, but since it's been buggy anyway (enums are indeed not polymorphic, but for int,... though gcc could have known better) that should hardly matter.
>     
>     @Marco
>     got that with gcc or clang? And which version and what specific call?
>     The constructor is (theoretically) correctly resolvable and if it's an ambiguous call, i'd expect a compiler error as well...
> 
> Kevin Ottens wrote:
>     Ah I see. Hm, is it very much used outside of the workspace?
> 
> Martin Gräßlin wrote:
>     > is it very much used outside of the workspace?
>     
>     probably not and ftr the ctors are SIC anyway compared to 4.x as it's now based on xcb
> 
> Kevin Ottens wrote:
>     I stand by my "ship it!" then.
> 
> Marco Martin wrote:
>     @Thomas: gcc 4.7.2 on opensuse
>     the error happens for instance in the virtual desktop KCM
>     NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout);
>     
>     NET::WM2DesktopLayout gets passed as screen
> 
> Thomas Lübking wrote:
>     Ahh...
>     
>           "You're holding it wrongly"™ ;-)
>     
>     typeof(NET::NumberOfDesktops | NET::DesktopNames) == typeof(int)
>     
>     NET::Property has no Q_DECLARE_OPERATORS_FOR_FLAGS (at least i don't see them) and thus "|" is the integer operator and the result is - integer.
>     
>     calling
>     NETRootInfo info(QX11Info::connection(), static_cast<NET::Property>(NET::NumberOfDesktops | NET::DesktopNames), NET::WM2DesktopLayout);
>     
>     should get you the correct result (but scratching the duplicated code is oc. fine anyway =)

yes, it does have Q_DECLARE_OPERATORS_FOR_FLAGS in the end of netwm_def.h
both Properties and Properties2

anyways, the problem is the last parameter, NET::WM2DesktopLayout that even if not or-ed, it gets casted as int anyways


- Marco


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118016/#review57407
-----------------------------------------------------------


On May 6, 2014, 12:47 p.m., Marco Martin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118016/
> -----------------------------------------------------------
> 
> (Updated May 6, 2014, 12:47 p.m.)
> 
> 
> Review request for KDE Frameworks and kwin.
> 
> 
> Repository: kwindowsystem
> 
> 
> Description
> -------
> 
> when the constructor
> NETRootInfo(xcb_connection_t *connection, NET::Properties properties, NET::Properties2 properties2,
>                 int screen = -1, bool doActivate = true);
> 
> gets called, NET::Properties2 gets casted as int and the other constructor
> 
> NETRootInfo(xcb_connection_t *connection, NET::Properties properties, int screen = -1, bool doActivate = true)
> 
> is called instead.
> 
> This patch merges the two constructors, fixing all the users of the first one
> 
> 
> Diffs
> -----
> 
>   autotests/netrootinfotestwm.cpp da7dcea 
>   src/netwm.h 7cbf2ab 
>   src/netwm.cpp a0e9105 
> 
> Diff: https://git.reviewboard.kde.org/r/118016/diff/
> 
> 
> Testing
> -------
> 
> screen and doActivate parameter weren't used by any, so all the currently ported software still builds and works correctly
> 
> 
> Thanks,
> 
> Marco Martin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140506/0e4b47c0/attachment.html>


More information about the Kde-frameworks-devel mailing list