Code review comment for lp://qastaging/~renatofilho/ubuntu-filemanager-app/fix-network-crash

Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> Another and easy approach would be if the class NetworkListWorker receive
> again a const DirItemInfo *parent, but sets m_parent as its own instance using
> the operator '=', in this case it never gets deleted outside the worker
> thread.
>
> Suppose the code changed:
>
>
> NetworkListWorker::NetworkListWorker(LocationItemDirIterator * dirIterator,
> DirItemInfo * mainItemInfo,
> const DirItemInfo *parent) :
> DirListWorker(dirIterator->path(),
> dirIterator->filters(),
> dirIterator->flags() == QDirIterator::Subdirectories ? true
> : false),
> m_dirIterator(dirIterator),
> m_mainItemInfo(mainItemInfo),
> m_parent(0)
> {
> if (parent != 0)
> {
> m_parent = new UrlItemInfo(); // UrlItemInfo is for remote
> *m_parent = *parent; // not sure it works, needs be reviewed
> }
> mLoaderType = NetworkLoader;
>
> // this would not be necessary and can be removed
> parent->connectDestructionSignal(this, SLOT(onParentDestroyed()));
> }
>
>
> NetworkListWorker::~NetworkListWorker()
> {
> delete m_dirIterator;
> delete m_mainItemInfo;
> if (m_parent != 0)
> {
> delete m_parent;
> }
> }

With that code the operation will be executed even after the "parent" object be destroyed what we do not want. It is waste of resource.

« Back to merge proposal