Changeset 347 for trunk/src


Ignore:
Timestamp:
Nov 24, 2009, 3:02:54 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui/kernel: mime: Unregister clipboard format atoms registered on behalf of mime converters upon destruction.

Location:
trunk/src/gui/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qmime.h

    r338 r347  
    142142
    143143    static ULONG registerMimeType(const QString &mime);
     144    static void unregisterMimeType(ULONG mimeId);
    144145
    145146    static ULONG allocateMemory(size_t size);
  • trunk/src/gui/kernel/qmime_pm.cpp

    r344 r347  
    169169
    170170/*!
     171    Unregisters the MIME type identified by \a id which was previously
     172    registered with registerMimeType().
     173*/
     174// static
     175void QPMMime::unregisterMimeType(ULONG mimeId)
     176{
     177    WinDeleteAtom(WinQuerySystemAtomTable(), mimeId);
     178}
     179
     180/*!
    171181    Allocates a block of shared memory of the given size and returns the address
    172182    of this block. This memory block may be then filled with data and returned
     
    366376public:
    367377    QPMMimeText();
     378    ~QPMMimeText();
    368379
    369380    // for converting from Qt
     
    388399    , CF_TextHtml (registerMimeType(QLatin1String("text/html")))
    389400{
     401}
     402
     403QPMMimeText::~QPMMimeText()
     404{
     405    unregisterMimeType(CF_TextHtml);
     406    unregisterMimeType(CF_TextUnicode);
    390407}
    391408
     
    645662public:
    646663    QPMMimeAnyMime();
     664    ~QPMMimeAnyMime();
    647665
    648666    // for converting from Qt
     
    692710}
    693711
     712QPMMimeAnyMime::~QPMMimeAnyMime()
     713{
     714    foreach(ULONG cf, cfMap.values())
     715        unregisterMimeType(cf);
     716}
     717
    694718QList<QPMMime::MimeCFPair> QPMMimeAnyMime::formatsForMimeData(const QMimeData *mimeData) const
    695719{
     
    819843    if (atomStr.startsWith(mimePrefix)) {
    820844        // the format represents the mime type we can recognize
     845        // increase the reference count
     846        ULONG cf = QPMMime::registerMimeType(atomStr);
     847        Q_ASSERT(cf == format);
     848        // extract the real mime type (w/o our prefix)
    821849        mime = atomStr.mid(mimePrefix.size());
    822850        if (!mime.isEmpty()) {
    823             cfMap[mime] = format;
    824             mimeMap[format] = mime;
     851            cfMap[mime] = cf;
     852            mimeMap[cf] = mime;
    825853        }
    826854    }
Note: See TracChangeset for help on using the changeset viewer.