~stolowski/unity-scopes-shell/art-uri-snap-root

« back to all changes in this revision

Viewing changes to src/Unity/settingsmodel.cpp

  • Committer: Bileto Bot
  • Author(s): Marcus Tomlinson
  • Date: 2016-10-04 08:59:14 UTC
  • mfrom: (345.1.1 trunk)
  • Revision ID: ci-train-bot@canonical.com-20161004085914-6oqgwuine69q82z4
Don't make changes to the settings model from a separate thread. (LP: #1627795)

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
 
159
159
QVariant SettingsModel::data(const QModelIndex& index, int role) const
160
160
{
161
 
    QMutexLocker locker(&m_mutex);
162
 
 
163
161
    int row = index.row();
164
162
    QVariant result;
165
163
 
255
253
 
256
254
QVariant SettingsModel::value(const QString& id) const
257
255
{
258
 
    QMutexLocker locker(&m_mutex);
259
 
 
260
256
    // Check for the setting id in the child scopes list first, in case the
261
257
    // aggregator is incorrectly using a scope id as a settings as well.
262
258
    if (m_child_scopes_data_by_id.contains(id))
313
309
 
314
310
void SettingsModel::update_child_scopes(QMap<QString, sc::ScopeMetadata::SPtr> const& scopes_metadata)
315
311
{
316
 
    QMutexLocker locker(&m_mutex);
317
 
 
318
312
    if (!scopes_metadata.contains(m_scopeId) ||
319
313
        !scopes_metadata[m_scopeId]->is_aggregator())
320
314
    {
369
363
        endResetModel();
370
364
    }
371
365
 
372
 
    locker.unlock();
373
366
    Q_EMIT countChanged();
374
367
}
375
368
 
376
369
bool SettingsModel::setData(const QModelIndex &index, const QVariant &value,
377
370
        int role)
378
371
{
379
 
    QMutexLocker locker(&m_mutex);
380
 
 
381
372
    int row = index.row();
382
373
    QVariant result;
383
374
 
441
432
 
442
433
int SettingsModel::count() const
443
434
{
444
 
    QMutexLocker locker(&m_mutex);
445
435
    return m_data.size() + m_child_scopes_data.size();
446
436
}
447
437
 
448
438
bool SettingsModel::require_child_scopes_refresh() const
449
439
{
450
 
    QMutexLocker locker(&m_mutex);
451
440
    return m_requireChildScopesRefresh;
452
441
}
453
442
 
454
443
void SettingsModel::settings_timeout()
455
444
{
456
 
    QMutexLocker locker(&m_mutex);
457
 
 
458
445
    QObject *timer = sender();
459
446
    if (!timer)
460
447
    {
478
465
            {
479
466
                m_scopeProxy->set_child_scopes(m_child_scopes);
480
467
 
481
 
                locker.unlock();
482
468
                Q_EMIT settingsChanged();
483
469
            }
484
470
            catch (std::exception const& e)
514
500
            FileLock lock = unixLock(m_settings_path, true);
515
501
            m_settings->sync(); // make sure the change to setting value is synced to fs
516
502
 
517
 
            locker.unlock();
518
503
            Q_EMIT settingsChanged();
519
504
        }
520
505
        catch(const unity::FileException& e)