ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #10121
[Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
Renato Araujo Oliveira Filho has proposed merging lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app.
Requested reviews:
Ubuntu File Manager Developers (ubuntu-filemanager-dev)
Related bugs:
Bug #1609051 in Ubuntu File Manager App: "File Manager crashes when Network is selected"
https://bugs.launchpad.net/ubuntu-filemanager-app/+bug/1609051
For more details, see:
https://code.launchpad.net/~renatofilho/ubuntu-filemanager-app/fix-network-crash/+merge/314870
--
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/diriteminfo.cpp'
--- src/plugin/folderlistmodel/diriteminfo.cpp 2015-12-12 12:30:47 +0000
+++ src/plugin/folderlistmodel/diriteminfo.cpp 2017-01-17 12:59:22 +0000
@@ -23,6 +23,8 @@
#include "locationurl.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <QMetaMethod>
+#include <QDebug>
QMimeDatabase DirItemInfoPrivate::mimeDatabase;
@@ -151,6 +153,13 @@
DirItemInfo::~DirItemInfo()
{
+ Q_FOREACH(const DestructionSlot &slot, d_ptr->_destructionSlots) {
+ if (slot.first) {
+ const QMetaObject *mObject = slot.first->metaObject();
+ QMetaMethod method = mObject->method(slot.second);
+ method.invoke(slot.first.data(), Qt::DirectConnection);
+ }
+ }
}
@@ -602,3 +611,13 @@
{
d_ptr->_isNetworkShare = true;
}
+
+void DirItemInfo::connectDestructionSignal(QObject *obj, const QByteArray &slot)
+{
+ int index = obj->metaObject()->indexOfSlot(slot.constData()+1);
+ if (index == -1) {
+ qWarning() << "Object" << obj << "does not has slot named:" << slot;
+ } else {
+ d_ptr->_destructionSlots.append(qMakePair(QPointer<QObject>(obj), index));
+ }
+}
=== modified file 'src/plugin/folderlistmodel/diriteminfo.h'
--- src/plugin/folderlistmodel/diriteminfo.h 2015-12-12 12:30:47 +0000
+++ src/plugin/folderlistmodel/diriteminfo.h 2017-01-17 12:59:22 +0000
@@ -30,6 +30,8 @@
#include <QDir>
#include <QMimeType>
#include <QMimeDatabase>
+#include <QPair>
+#include <QPointer>
class DirItemInfoPrivate;
@@ -114,6 +116,7 @@
void fillFromStatBuf(const struct stat& statBuffer);
void setAsHost();
void setAsShare();
+ void connectDestructionSignal(QObject *obj, const QByteArray &slot);
public:
static QString removeExtraSlashes(const QString &url, int firstSlashIndex = -1);
@@ -134,6 +137,7 @@
};
typedef QVector<DirItemInfo> DirItemInfoList;
+typedef QPair<QPointer<QObject>, int> DestructionSlot;
Q_DECLARE_SHARED(DirItemInfo)
Q_DECLARE_METATYPE(DirItemInfo)
@@ -180,6 +184,8 @@
QString _normalizedPath;
QString _authenticationPath;
+ QVector<DestructionSlot> _destructionSlots;
+
static QMimeDatabase mimeDatabase;
};
=== modified file 'src/plugin/folderlistmodel/iorequestworker.cpp'
--- src/plugin/folderlistmodel/iorequestworker.cpp 2013-10-12 19:25:17 +0000
+++ src/plugin/folderlistmodel/iorequestworker.cpp 2017-01-17 12:59:22 +0000
@@ -36,6 +36,8 @@
#include <QDateTime>
#include <QDebug>
+#define ORIGNAL_THREAD "ORIGINAL_THREAD"
+
/*!
Lives on an IOWorkerThread.
@@ -55,6 +57,7 @@
<< Q_FUNC_INFO;
#endif
+ request->setProperty(ORIGNAL_THREAD, QVariant::fromValue<QThread*>(request->thread()));
request->moveToThread(this);
// TODO: queue requests so we run the most important one first
@@ -82,7 +85,11 @@
lock.unlock();
request->run();
+
+ // transfer back to main loop to make sure that will be destoyed by deleteLater
+ request->moveToThread(request->property(ORIGNAL_THREAD).value<QThread*>());
request->deleteLater();
+
lock.relock();
}
}
=== modified file 'src/plugin/folderlistmodel/location.cpp'
--- src/plugin/folderlistmodel/location.cpp 2015-12-08 16:55:41 +0000
+++ src/plugin/folderlistmodel/location.cpp 2017-01-17 12:59:22 +0000
@@ -326,6 +326,5 @@
{
m_info = new DirItemInfo();
}
- refreshInfo(); //update information
return m_info;
}
=== modified file 'src/plugin/folderlistmodel/location.h'
--- src/plugin/folderlistmodel/location.h 2015-12-12 13:59:49 +0000
+++ src/plugin/folderlistmodel/location.h 2017-01-17 12:59:22 +0000
@@ -91,6 +91,9 @@
virtual void setAuthentication(const QString& user,
const QString& password);
+private slots:
+ void onParentDestroyed();
+
public: //pure functions
/*!
=== modified file 'src/plugin/folderlistmodel/networklistworker.cpp'
--- src/plugin/folderlistmodel/networklistworker.cpp 2015-12-12 14:32:18 +0000
+++ src/plugin/folderlistmodel/networklistworker.cpp 2017-01-17 12:59:22 +0000
@@ -23,8 +23,10 @@
#include "locationitemdiriterator.h"
#include "locationurl.h"
+#include <QDebug>
+
NetworkListWorker::NetworkListWorker(LocationItemDirIterator * dirIterator,
- DirItemInfo * mainItemInfo, const DirItemInfo *parent) :
+ DirItemInfo * mainItemInfo, DirItemInfo *parent) :
DirListWorker(dirIterator->path(),
dirIterator->filters(),
dirIterator->flags() == QDirIterator::Subdirectories ? true : false),
@@ -33,6 +35,7 @@
m_parent(parent)
{
mLoaderType = NetworkLoader;
+ parent->connectDestructionSignal(this, SLOT(onParentDestroyed()));
}
@@ -42,10 +45,18 @@
delete m_mainItemInfo;
}
+void NetworkListWorker::onParentDestroyed()
+{
+ m_parent = 0;
+}
DirItemInfoList NetworkListWorker::getNetworkContent()
{
DirItemInfoList netContent;
+
+ if (!m_parent)
+ return netContent;
+
m_dirIterator->load();
bool is_parent_of_smb_url = m_parent != 0 && m_parent->urlPath().startsWith(LocationUrl::SmbURL);
while (m_dirIterator->hasNext())
=== modified file 'src/plugin/folderlistmodel/networklistworker.h'
--- src/plugin/folderlistmodel/networklistworker.h 2015-12-12 14:32:18 +0000
+++ src/plugin/folderlistmodel/networklistworker.h 2017-01-17 12:59:22 +0000
@@ -40,11 +40,15 @@
public:
NetworkListWorker(LocationItemDirIterator * dirIterator,
DirItemInfo * mainItemInfo,
- const DirItemInfo * parent = 0);
+ DirItemInfo * parent = 0);
~NetworkListWorker();
+public slots:
+ void onParentDestroyed();
+
protected:
virtual DirItemInfoList getNetworkContent();
void setSmbItemAttributes();
+
protected:
LocationItemDirIterator * m_dirIterator;
DirItemInfo * m_mainItemInfo;
Follow ups
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Jenkins Bot, 2017-02-17
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Renato Araujo Oliveira Filho, 2017-01-27
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-26
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-26
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-26
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Arto Jalkanen, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Pat McGowan, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-25
-
[Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Renato Araujo Oliveira Filho, 2017-01-25
-
[Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Renato Araujo Oliveira Filho, 2017-01-25
-
[Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Renato Araujo Oliveira Filho, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Carlos Jose Mazieri, 2017-01-25
-
Re: [Merge] lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
From: Pat McGowan, 2017-01-24