Project

General

Profile

Actions

Feature #456

open

WSharedProxyModel: share abstract item models between applications

Added by Anonymous over 13 years ago. Updated over 11 years ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
-
Start date:
07/30/2010
Due date:
% Done:

0%

Estimated time:

Description

IWSharedProxyModel needs to do two things:

  • protected access to the source model
  • propagate signals to connected views while holding the update lock (and correct WApplication::instance()) for that view's application.

The implementation in my previous email will probably not work, since it cannot avoid a dead-lock situation: one app tries to modify the model, while another app is busy reading from the model: the writing operation would block further reads until it is done (including signal propagation), but it would not be able to get the update lock for the application that is being blocked trying to read from the model.

The implementation should do:

  • when writing:
    1) grab update locks for all registered applications
    2) do the write operation in the source model
    3) for the signals emitted from the source model:
    • app->attachThread()
    • propagate to app

<!-- -->

  • when reading:
    no (additional) lock needed - writing will take the update lock of all registered applications, so it cannot happen concurrently with readers.
    reading is allow concurrently

<!-- -->

  • We make the calls to the signal accessor methods of WAbstractItemModel (such as changed()) virtual to have something like this:

with:

typedef std::map<WApplication *app, Signal<WModelIndex, WModelIndex>> ChangedSignalsMap;
ChangedSignalsMap changedSignals_;

we could reimplement changed():

Signal<WModelIndex, WModelIndex>& WSharedProxyModel::changed()
{
  WApplication *app = WApplication::instance();
  return changedSignals_[app];
}

and the method that propagates the change from the source model:

void WSharedProxyModel::sourceModelChanged(const WModelIndex& m1, const WModelIndex& m2)
{
  for (ChangedSignalsMap::const_iterator i = changedSignals_.begin(); i != changedSignals_.end(); ++i) {
    i->first->attachThread(); // we already have the update lock cfr supra
    i->second.emit(m1, m2);
  }
}
Actions #1

Updated by Koen Deforche over 11 years ago

Hey,

Just a good idea on this.

We should be able to share the main body of logic in WBatchEditProxyModel here, to shield changes from the source model to the views until we have the lock. This will simplify the implementation of this class significantly !

Regards,

kone

Actions #2

Updated by Стойчо Стефанов Stoycho Stefanov over 11 years ago

Hey,

I need this feature as well!

Actions #3

Updated by Niko Weh over 11 years ago

This functionality would be really helpful.

(Sorry should there be a "vote button" somewhere, i couldn't find it)

Actions

Also available in: Atom PDF