Two occurrences of Open Picture.. option in Picture Frame menu

Aaron J. Seigo aseigo at kde.org
Thu Aug 6 23:26:32 CEST 2009


On Thursday 06 August 2009, Shantanu Tushar Jha wrote:
> Hi,
> I had fixed the non-appearance of Open Picture... option in Picture
> Frame's right-click menu ( r990567and r991008 ). But weirdly,
> sometimes there are two instances of the Open Picture... option. But,
> the code does check for it that multiple options aren't added (using
> the variable m_menuPresent ) -
>
>  if (hasAuthorization("LaunchApp") && ! (m_menuPresent || m_potd ||
> (m_currentUrl.path() == "Default" && m_mySlideShow->currentUrl() ==
> "Default")))

i assume the missing '{' is just an accident :)

anyways, the logic of this if statement is pretty complex. personally, i'd 
write it like this:

const bool invalid = m_currentUrl.path() == "Default" && 
                     m_mySlideShow->currentUrl() == "Default";

if (m_potd || invalid) {
    delete m_openPicture;
    m_openPicture = 0;
} else if (!m_openPicture && hasAuthorization("LaunchApp")) {
   ...
}

does the same thing, but so much easier to read and understand imho. note that 
this also gets rid of the need for m_menuPresent.

> I tried a lot to figure it out, but the maximum i can guess is that
> the code is getting run twice simultaneously. 

that's not possible. maybe put some debug input in there that shows the values 
of what's being used in the if/else statements.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Software
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20090806/2f2f8716/attachment-0001.sig 


More information about the Plasma-devel mailing list