]> git.lyx.org Git - features.git/commitdiff
More idiomatic way of checking if a shared_ptr has an associated managed object
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 21 Oct 2012 19:04:05 +0000 (21:04 +0200)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 25 Oct 2012 10:12:49 +0000 (12:12 +0200)
src/KeyMap.cpp
src/frontends/qt4/LayoutBox.cpp
src/graphics/GraphicsCacheItem.cpp
src/graphics/GraphicsLoader.cpp
src/support/ForkedCalls.cpp

index ffd55c4970a01865515bf71f28a43c550d37fcb8..50833c923a755d694fd7042082aca99362cc6156 100644 (file)
@@ -115,13 +115,12 @@ void KeyMap::bind(KeySequence * seq, FuncRequest const & func, unsigned int r)
                                LYXERR(Debug::KBMAP, "Warning: New binding for '"
                                        << to_utf8(seq->print(KeySequence::Portable))
                                        << "' is overriding old binding...");
-                               if (it->prefixes.get()) {
+                               if (it->prefixes)
                                        it->prefixes.reset();
-                               }
                                it->func = func;
                                it->func.setOrigin(FuncRequest::KEYBOARD);
                                return;
-                       } else if (!it->prefixes.get()) {
+                       } else if (!it->prefixes) {
                                lyxerr << "Error: New binding for '"
                                       << to_utf8(seq->print(KeySequence::Portable))
                                       << "' is overriding old binding..."
@@ -168,10 +167,10 @@ void KeyMap::unbind(KeySequence * seq, FuncRequest const & func, unsigned int r)
                        if (r + 1 == seq->length()) {
                                if (it->func == func) {
                                        remove = it;
-                                       if (it->prefixes.get())
+                                       if (it->prefixes)
                                                it->prefixes.reset();
                                }
-                       } else if (it->prefixes.get()) {
+                       } else if (it->prefixes) {
                                it->prefixes->unbind(seq, func, r + 1);
                                if (it->prefixes->empty())
                                        remove = it;
@@ -201,7 +200,7 @@ FuncRequest KeyMap::getBinding(KeySequence const & seq, unsigned int r)
                    && mod2 == it->mod.second) {
                        if (r + 1 == seq.length())
                                return it->func;
-                       else if (it->prefixes.get())
+                       else if (it->prefixes)
                                return it->prefixes->getBinding(seq, r + 1);
                }
        }
@@ -441,7 +440,7 @@ FuncRequest const & KeyMap::lookup(KeySymbol const &key,
 
                if (cit->code == key && cit->mod.first == check) {
                        // match found
-                       if (cit->prefixes.get()) {
+                       if (cit->prefixes) {
                                // this is a prefix key - set new map
                                seq->curmap = cit->prefixes.get();
                                static FuncRequest prefix(LFUN_COMMAND_PREFIX);
@@ -507,7 +506,7 @@ KeyMap::Bindings KeyMap::findBindings(FuncRequest const & func,
 
        Table::const_iterator end = table.end();
        for (Table::const_iterator cit = table.begin(); cit != end; ++cit) {
-               if (cit->prefixes.get()) {
+               if (cit->prefixes) {
                        KeySequence seq = prefix;
                        seq.addkey(cit->code, cit->mod.first);
                        Bindings res2 = cit->prefixes->findBindings(func, seq);
@@ -555,7 +554,7 @@ void KeyMap::listBindings(BindingList & list,
        Table::const_iterator it_end = table.end();
        for (; it != it_end; ++it) {
                // a LFUN_COMMAND_PREFIX
-               if (it->prefixes.get()) {
+               if (it->prefixes) {
                        KeySequence seq = prefix;
                        seq.addkey(it->code, it->mod.first);
                        it->prefixes->listBindings(list, seq, tag);
index aa22e60eaca8d2290dd4e43d15f7842aa7a2230f..e11a63dde7c61bb735f4e2545b53d4d958eb03ac 100644 (file)
@@ -536,7 +536,7 @@ void LayoutBox::set(docstring const & layout)
 {
        d->resetFilter();
 
-       if (!d->text_class_.get())
+       if (!d->text_class_)
                return;
 
        if (!d->text_class_->hasLayout(layout))
@@ -691,7 +691,7 @@ void LayoutBox::selected(int index)
                d->model_->itemFromIndex(mindex)->text());
        d->owner_.setFocus();
 
-       if (!d->text_class_.get()) {
+       if (!d->text_class_) {
                updateContents(false);
                d->resetFilter();
                return;
index fafa78bdcb2b68b2908eb67303b274e96632011f..8183fea61e4523078c0cdaa31ee5abc761b936b5 100644 (file)
@@ -235,7 +235,7 @@ void CacheItem::Impl::reset()
        file_to_load_.erase();
        to_.erase();
 
-       if (image_.get())
+       if (image_)
                image_.reset();
 
        status_ = WaitingToLoad;
index 36f2839446bbd12f5e0e4cc4b9cf9860f217e438..f635e0b321f6b8e625f53bf469d8811adce36779 100644 (file)
@@ -273,7 +273,7 @@ void Loader::reset(Params const & params) const
 
 void Loader::startLoading() const
 {
-       if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get())
+       if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_)
                return;
        pimpl_->startLoading();
 }
@@ -287,7 +287,7 @@ void Loader::reload() const
 
 void Loader::startMonitoring() const
 {
-       if (!pimpl_->cached_item_.get())
+       if (!pimpl_->cached_item_)
                return;
 
        pimpl_->cached_item_->startMonitoring();
@@ -296,7 +296,7 @@ void Loader::startMonitoring() const
 
 bool Loader::monitoring() const
 {
-       if (!pimpl_->cached_item_.get())
+       if (!pimpl_->cached_item_)
                return false;
 
        return pimpl_->cached_item_->monitoring();
@@ -305,7 +305,7 @@ bool Loader::monitoring() const
 
 unsigned long Loader::checksum() const
 {
-       if (!pimpl_->cached_item_.get())
+       if (!pimpl_->cached_item_)
                return 0;
 
        return pimpl_->cached_item_->checksum();
@@ -315,7 +315,7 @@ unsigned long Loader::checksum() const
 FileName const & Loader::filename() const
 {
        static FileName const empty;
-       return pimpl_->cached_item_.get() ?
+       return pimpl_->cached_item_ ?
                pimpl_->cached_item_->filename() : empty;
 }
 
@@ -352,7 +352,7 @@ Loader::Impl::~Impl()
 
 void Loader::Impl::resetFile(FileName const & file)
 {
-       FileName const old_file = cached_item_.get() ?
+       FileName const old_file = cached_item_ ?
                cached_item_->filename() : FileName();
 
        if (file == old_file)
@@ -375,10 +375,10 @@ void Loader::Impl::resetFile(FileName const & file)
                }
        }
 
-       status_ = cached_item_.get() ? cached_item_->status() : WaitingToLoad;
+       status_ = cached_item_ ? cached_item_->status() : WaitingToLoad;
        image_.reset();
 
-       if (cached_item_.get() || file.empty())
+       if (cached_item_ || file.empty())
                return;
 
        Cache & gc = Cache::get();
@@ -402,14 +402,14 @@ void Loader::Impl::resetParams(Params const & params)
                return;
 
        params_ = params;
-       status_ = cached_item_.get() ? cached_item_->status() : WaitingToLoad;
+       status_ = cached_item_ ? cached_item_->status() : WaitingToLoad;
        image_.reset();
 }
 
 
 void Loader::Impl::statusChanged()
 {
-       status_ = cached_item_.get() ? cached_item_->status() : WaitingToLoad;
+       status_ = cached_item_ ? cached_item_->status() : WaitingToLoad;
        createPixmap();
        signal_();
 }
@@ -420,7 +420,7 @@ void Loader::Impl::createPixmap()
        if (!params_.display || status_ != Loaded)
                return;
 
-       if (!cached_item_.get()) {
+       if (!cached_item_) {
                LYXERR(Debug::GRAPHICS, "pixmap not cached yet");
                return;
        }
index 1c5e663723f765e3aa547e4b108d729135007fdc..0378b05bf1c6e7ab43e907a58cbed1c5be11dad7 100644 (file)
@@ -113,7 +113,7 @@ bool ForkedProcess::IAmAChild = false;
 
 void ForkedProcess::emitSignal()
 {
-       if (signal_.get()) {
+       if (signal_) {
                signal_->operator()(pid_, retval_);
        }
 }