Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8834


Ignore:
Timestamp:
Aug 12, 2011, 12:26:40 AM (13 years ago)
Author:
landauf
Message:

added flag to disable automatic registration of output listeners. avoids crash during creation of a Shell if some verbose context (object_list?) is activated.
different handling of sub-contexts whose main-context is also explicitly registered (even though that's not the intended way to use)

Location:
code/branches/output/src/libraries
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/core/command/Shell.cc

    r8833 r8834  
    3939#include "util/StringUtils.h"
    4040#include "util/SubString.h"
     41#include "util/output/OutputManager.h"
    4142#include "util/output/MemoryWriter.h"
    4243#include "core/CoreIncludes.h"
     
    7172    */
    7273    Shell::Shell(const std::string& consoleName, bool bScrollable)
    73         : BaseWriter(consoleName)
     74        : BaseWriter(consoleName, false)
    7475        , inputBuffer_(new InputBuffer())
    7576        , bScrollable_(bScrollable)
    7677    {
    7778        RegisterRootObject(Shell);
     79
     80        OutputManager::getInstance().registerListener(this);
    7881
    7982        this->scrollPosition_ = 0;
     
    104107    {
    105108        this->inputBuffer_->destroy();
     109
     110        OutputManager::getInstance().unregisterListener(this);
    106111    }
    107112
  • code/branches/output/src/libraries/util/output/BaseWriter.cc

    r8833 r8834  
    3333namespace orxonox
    3434{
    35     BaseWriter::BaseWriter(const std::string& name)
     35    BaseWriter::BaseWriter(const std::string& name, bool bRegister) : OutputListener(bRegister)
    3636    {
    3737        this->name_ = name;
     
    4242
    4343        this->subcontextsCheckMask_ = context::none;
     44        this->subcontextsNoCheckMask_ = context::none;
    4445
    4546        this->changedConfigurableLevel();
     
    5455    void BaseWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
    5556    {
    56         if (((this->subcontextsCheckMask_ & context.mask) == 0) || (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end()))
     57        if (((this->subcontextsCheckMask_ & context.mask) == 0) ||
     58            (this->subcontextsNoCheckMask_ & context.mask) ||
     59            (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end()))
    5760        {
    5861            const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
     
    9093        OutputContextMask context_mask = context::none;
    9194        this->subcontextsCheckMask_ = context::none;
     95        this->subcontextsNoCheckMask_ = context::none;
    9296
    9397        this->subcontexts_.clear();
    94         this->subcontexts_.insert(context::no_subcontext);
    9598
    9699        for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)
     
    117120                this->subcontextsCheckMask_ |= container.mask;
    118121            }
     122            else
     123            {
     124                this->subcontextsNoCheckMask_ |= container.mask;
     125            }
    119126        }
    120127
  • code/branches/output/src/libraries/util/output/BaseWriter.h

    r8833 r8834  
    4242    {
    4343        public:
    44             BaseWriter(const std::string& name);
     44            BaseWriter(const std::string& name, bool bRegister = true);
    4545            virtual ~BaseWriter();
    4646
     
    8585
    8686            OutputContextMask subcontextsCheckMask_;
     87            OutputContextMask subcontextsNoCheckMask_;
    8788            std::set<OutputContextSubID> subcontexts_;
    8889    };
  • code/branches/output/src/libraries/util/output/OutputListener.cc

    r8833 r8834  
    3333namespace orxonox
    3434{
    35     OutputListener::OutputListener()
     35    OutputListener::OutputListener(bool bRegister)
    3636    {
    3737        this->levelMask_ = level::none;
     
    3939        this->additionalContextsMask_ = context::none;
    4040
    41         OutputManager::getInstance().registerListener(this);
     41        if (bRegister)
     42            OutputManager::getInstance().registerListener(this);
    4243    }
    4344
  • code/branches/output/src/libraries/util/output/OutputListener.h

    r8833 r8834  
    4141    {
    4242        public:
    43             OutputListener();
     43            OutputListener(bool bRegister = true);
    4444            virtual ~OutputListener();
    4545
Note: See TracChangeset for help on using the changeset viewer.