Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
use automatic storage for the Property
Until performance measurements show it should be optimized :)

Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Nov 6, 2015
1 parent cf0a4f9 commit efa3ea4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/contextkit-subscriber/property.cpp
Expand Up @@ -506,7 +506,7 @@ void PropertyMonitor::subscribe(SubscribeRequest *req)
{
auto tgt = req->tgt_;
auto key = req->key_;
Property *handler;
std::shared_ptr<Property> handler;
QVariant retval;

if (!tgt) {
Expand Down Expand Up @@ -544,7 +544,6 @@ void PropertyMonitor::unsubscribe(UnsubscribeRequest *req)
if (handler->remove(tgt) == Property::Removed::Last) {
// last subscriber is gone
properties_.erase(phandlers);
handler->deleteLater();
}
}

Expand All @@ -559,9 +558,10 @@ void PropertyMonitor::refresh(RefreshRequest *req)
handler->update();
}

Property* PropertyMonitor::add(const QString &key)
std::shared_ptr<Property> PropertyMonitor::add(const QString &key)
{
auto it = properties_.insert(key, new Property(key, this));
auto it = properties_.insert
(key, make_qobject_shared<Property>(key, this));
return it.value();
}

Expand Down
4 changes: 2 additions & 2 deletions src/contextkit-subscriber/property.hpp
Expand Up @@ -181,11 +181,11 @@ class PropertyMonitor : public QObject
private:
void subscribe(SubscribeRequest*);
void unsubscribe(UnsubscribeRequest*);
Property *add(const QString &);
std::shared_ptr<Property> add(const QString &);
void write(WriteRequest *);
void refresh(RefreshRequest*);

QMap<QString, Property*> properties_;
QMap<QString, std::shared_ptr<Property> > properties_;

static std::once_flag once_;
static monitor_ptr instance_;
Expand Down

0 comments on commit efa3ea4

Please sign in to comment.