mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
FolderMan: fix some signal-slot broken connection
In many cases the alias was changed to a Folder pointer
This commit is contained in:
parent
389c4f8ef9
commit
de9770f52a
@ -55,10 +55,6 @@ FolderMan::FolderMan(QObject *parent) :
|
||||
QObject(parent),
|
||||
_syncEnabled( true )
|
||||
{
|
||||
_folderChangeSignalMapper = new QSignalMapper(this);
|
||||
connect(_folderChangeSignalMapper, SIGNAL(mapped(const QString &)),
|
||||
this, SIGNAL(folderSyncStateChange(const QString &)));
|
||||
|
||||
Q_ASSERT(!_instance);
|
||||
_instance = this;
|
||||
|
||||
@ -400,14 +396,11 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
|
||||
_disabledFolders.insert(folder);
|
||||
}
|
||||
|
||||
/* Use a signal mapper to connect the signals to the alias */
|
||||
connect(folder, SIGNAL(scheduleToSync(Folder*)), SLOT(slotScheduleSync(Folder*)));
|
||||
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
||||
connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChanged()));
|
||||
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
||||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||
|
||||
_folderChangeSignalMapper->setMapping( folder, folder->alias() );
|
||||
|
||||
registerFolderMonitor(folder);
|
||||
return folder;
|
||||
}
|
||||
@ -478,7 +471,7 @@ void FolderMan::slotScheduleSync( Folder *f )
|
||||
// We want the SocketAPI to already now update so that it can show the EVAL icon
|
||||
// for files/folders. Only do this when not syncing, else we might get a lot
|
||||
// of those notifications.
|
||||
_socketApi->slotUpdateFolderView(alias);
|
||||
_socketApi->slotUpdateFolderView(f);
|
||||
}
|
||||
|
||||
qDebug() << "Schedule folder " << alias << " to sync!";
|
||||
@ -489,7 +482,7 @@ void FolderMan::slotScheduleSync( Folder *f )
|
||||
} else {
|
||||
qDebug() << "Folder is not enabled, not scheduled!";
|
||||
if( _socketApi ) {
|
||||
_socketApi->slotUpdateFolderView(f->alias());
|
||||
_socketApi->slotUpdateFolderView(f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -706,6 +699,14 @@ void FolderMan::slotFolderSyncFinished( const SyncResult& )
|
||||
startScheduledSyncSoon();
|
||||
}
|
||||
|
||||
void FolderMan::slotFolderSyncStateChanged()
|
||||
{
|
||||
auto f = qobject_cast<Folder *>(sender());
|
||||
Q_ASSERT(f);
|
||||
emit folderSyncStateChange(f);
|
||||
}
|
||||
|
||||
|
||||
Folder* FolderMan::addFolder(AccountState* accountState, const FolderDefinition& folderDefinition)
|
||||
{
|
||||
if (!ensureJournalGone(folderDefinition.localPath)) {
|
||||
@ -730,11 +731,10 @@ Folder* FolderMan::addFolderInternal(AccountState* accountState, const FolderDef
|
||||
|
||||
/* Use a signal mapper to connect the signals to the alias */
|
||||
connect(folder, SIGNAL(scheduleToSync(Folder*)), SLOT(slotScheduleSync(Folder*)));
|
||||
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
||||
connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChanged()));
|
||||
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
||||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||
|
||||
_folderChangeSignalMapper->setMapping( folder, folder->alias() );
|
||||
|
||||
registerFolderMonitor(folder);
|
||||
return folder;
|
||||
|
||||
@ -131,6 +131,7 @@ private slots:
|
||||
void slotEtagPollTimerTimeout();
|
||||
|
||||
void slotRemoveFoldersForAccount(AccountState* accountState);
|
||||
void slotFolderSyncStateChanged();
|
||||
|
||||
private:
|
||||
/** Adds a folder for an account, does not add it to the account settings.
|
||||
@ -153,7 +154,6 @@ private:
|
||||
QSet<Folder*> _disabledFolders;
|
||||
Folder::Map _folderMap;
|
||||
QString _folderConfigPath;
|
||||
QSignalMapper *_folderChangeSignalMapper;
|
||||
Folder *_currentSyncFolder = 0;
|
||||
QPointer<Folder> _lastSyncFolder;
|
||||
bool _syncEnabled;
|
||||
|
||||
@ -82,8 +82,8 @@ SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
|
||||
addPreferencesPanel(networkIcon, tr("Network"), networkSettings);
|
||||
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
|
||||
this, SLOT(slotSyncStateChange(QString)));
|
||||
connect( folderMan, SIGNAL(folderSyncStateChange(Folder*)),
|
||||
this, SLOT(slotSyncStateChange(Folder*)));
|
||||
|
||||
connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged()));
|
||||
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
|
||||
@ -101,11 +101,8 @@ SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
|
||||
cfg.restoreGeometry(this);
|
||||
}
|
||||
|
||||
void SettingsDialogMac::slotSyncStateChange(const QString& alias)
|
||||
void SettingsDialogMac::slotSyncStateChange(Folder *folder)
|
||||
{
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
|
||||
Folder *folder = folderMan->folder(alias);
|
||||
if( folder ) {
|
||||
_accountSettings->slotUpdateFolderState(folder);
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
void setGeneralErrors( const QStringList& errors );
|
||||
|
||||
public slots:
|
||||
void slotSyncStateChange(const QString& alias);
|
||||
void slotSyncStateChange(Folder *);
|
||||
void showActivityPage();
|
||||
|
||||
private:
|
||||
|
||||
@ -127,7 +127,7 @@ SocketApi::SocketApi(QObject* parent)
|
||||
connect(&_localServer, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
||||
|
||||
// folder watcher
|
||||
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(QString)), this, SLOT(slotUpdateFolderView(QString)));
|
||||
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)), this, SLOT(slotUpdateFolderView(Folder*)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString, const SyncFileItem &)),
|
||||
SLOT(slotJobCompleted(QString, const SyncFileItem &)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString, const SyncFileItem &)),
|
||||
@ -261,13 +261,12 @@ void SocketApi::slotUnregisterPath( const QString& alias )
|
||||
}
|
||||
}
|
||||
|
||||
void SocketApi::slotUpdateFolderView(const QString& alias)
|
||||
void SocketApi::slotUpdateFolderView(Folder *f)
|
||||
{
|
||||
if (_listeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Folder *f = FolderMan::instance()->folder(alias);
|
||||
if (f) {
|
||||
// do only send UPDATE_VIEW for a couple of status
|
||||
if( f->syncResult().status() == SyncResult::SyncPrepare ||
|
||||
@ -282,7 +281,7 @@ void SocketApi::slotUpdateFolderView(const QString& alias)
|
||||
|
||||
broadcastMessage(QLatin1String("UPDATE_VIEW"), f->path() );
|
||||
} else {
|
||||
qDebug() << "Not sending UPDATE_VIEW for" << alias << "because status() is" << f->syncResult().status();
|
||||
qDebug() << "Not sending UPDATE_VIEW for" << f->alias() << "because status() is" << f->syncResult().status();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public:
|
||||
virtual ~SocketApi();
|
||||
|
||||
public slots:
|
||||
void slotUpdateFolderView(const QString&);
|
||||
void slotUpdateFolderView(Folder *f);
|
||||
void slotUnregisterPath( const QString& alias );
|
||||
void slotRegisterPath( const QString& alias );
|
||||
void slotReadExcludes();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user