Diffusion Ark a530116b619a

[GSoC] Refactor ArchiveNode and ArchiveDirNode classes

Authored by mvlabat on May 24 2016, 7:48 PM.

Description

[GSoC] Refactor ArchiveNode and ArchiveDirNode classes

Refactor ArchiveNode and ArchiveDirNode classes to Archive::Entry class
and move its declaration to kerfuffle/archiveentry.h file.

Make Archive::Entry store meta data in Q_PROPERTY members.

Move EntryMetaDataType to part/archivemodel.cpp.

Delete duplicated directory entries while reading from 7z archives.

See:
https://phabricator.kde.org/T2704

Details

Good work. I'm only afraid by the fact that we are moving from ArchiveEntry references to Archive::Entry pointers all over the place. This means that we need to be more careful about the memory management, or otherwise we are going to have memory leaks.

In particular, the Entry class is a QObject but doesn't take a QObject parent in the constructor. This is risky and error prone. How about something like this:

Archive::Entry::Entry(QObject *parent)
    : QObject(parent)
    // other stuff
{
    if (qobject_cast<Entry*>(parent) {
        m_parent = parent;
    }

    // other stuff
}

This way we are using the Qt memory model and this will simplify the things.

/autotests/kerfuffle/jsonarchiveinterface.cpp
76

This will leak memory, since you're allocating e on the heap. I think here you can just create e on the stack (i.e. Kerfuffle::Archive::Entry e;).

/autotests/kerfuffle/jsonparser.cpp
66

Same here, e will leak. Try to allocate on the stack if possible.

/part/archivemodel.cpp
633–638

This part is a bit obscure. I don't understand why the "compressed size" property needs this special treatment. Maybe this is just a workaround for a bug somewhere else?

/plugins/clirarplugin/cliplugin.cpp
31

Please remove these spaces.