[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Where's 'wxDataFormat("Link")' implemented?

From: Greg Chicares
Subject: Re: [lmi] Where's 'wxDataFormat("Link")' implemented?
Date: Mon, 25 Feb 2008 16:38:37 +0000
User-agent: Thunderbird (Windows/20071031)

On 2008-02-25 04:06Z, Greg Chicares wrote:

[...consolidating and simplifying lmi clipboard code, and in
particular making it ignore any data format other than wxDF_TEXT]

> Changed 20080224T1711Z.

Now I've got this, and I'm wondering if it can be simplified further:

/// Return whatever plain text the clipboard contains, or an empty
/// string if it contains none.
/// Throw an exception if the clipboard cannot be locked.

std::string ClipboardEx::GetText()
    wxClipboardLocker lock;
        fatal_error() << "Unable to lock clipboard." << LMI_FLUSH;

        return std::string();

    wxTextDataObject z;
    return std::string(z.GetText());

Is it safe to remove the special case
    if(!wxTheClipboard->IsSupported(wxDF_TEXT)) [...return early]
and rely on the last three lines to return an empty string if
there's no wxDF_TEXT on the clipboard, without even bothering to
check the return code of GetData()? That simplification seems
to work fine with msw, but I thought I'd better ask first for
fear of undefined behavior in some case on some platform.

(I explicitly construct a std::string on the last line in order
to avoid any potential problem with automatic conversion from

reply via email to

[Prev in Thread] Current Thread [Next in Thread]