Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 19, 2008, 4:10:27 AM (16 years ago)
Author:
landauf
Message:
  • fixed bug #1 in ConfigValueContainer (callback not being called the first time)
  • fixed another bug in XMLPort, caused by the recently added support for extern types
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/ConfigValueContainer.h

    r1596 r1610  
    103103            ConfigValueContainer& getValue(T* value, C* object)
    104104            {
    105                 if (this->callback_ && object)
    106                 {
     105std::cout << "start: " << this->getName() << std::endl;
     106                if ((this->callback_ && object) || this->bContainerIsNew_)
     107                {
     108                    if (this->bContainerIsNew_)
     109                        this->bContainerIsNew_ = false;
     110
    107111                    T temp = *value;
    108112                    this->value_.getValue(value);
    109113                    if ((*value) != temp)
    110                         this->callback_->call(object);
     114                    {
     115                        if (this->callback_ && object)
     116                            this->callback_->call(object);
     117                        else
     118                            this->bDoInitialCallback_ = true;
     119                    }
    111120                }
    112121                else
     
    114123                    this->value_.getValue(value);
    115124                }
     125std::cout << "end" << std::endl;
    116126                return *this;
    117127            }
     
    121131            ConfigValueContainer& getValue(std::vector<T>* value, C* object)
    122132            {
    123                 if (this->callback_ && object)
    124                 {
     133                if ((this->callback_ && object) || this->bContainerIsNew_)
     134                {
     135                    if (this->bContainerIsNew_)
     136                        this->bContainerIsNew_ = false;
     137
    125138                    std::vector<T> temp = *value;
    126 
    127139                    value->clear();
    128140                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
     
    131143                    if (value->size() != temp.size())
    132144                    {
    133                         this->callback_->call(object);
     145                        if (this->callback_ && object)
     146                            this->callback_->call(object);
     147                        else
     148                            this->bDoInitialCallback_ = true;
    134149                    }
    135150                    else
     
    139154                            if ((*value)[i] != temp[i])
    140155                            {
    141                                 this->callback_->call(object);
     156                                if (this->callback_ && object)
     157                                    this->callback_->call(object);
     158                                else
     159                                    this->bDoInitialCallback_ = true;
    142160                                break;
    143161                            }
     
    172190
    173191            template <class T>
    174             inline ConfigValueContainer& callback(void (T::*function) (void))
     192            inline ConfigValueContainer& callback(T* object, void (T::*function) (void))
    175193            {
    176194                if (!this->callback_)
     195                {
    177196                    this->callback_ = new ConfigValueCallback<T>(function);
     197
     198                    if (this->bDoInitialCallback_)
     199                    {
     200                        this->bDoInitialCallback_ = false;
     201                        this->callback_->call(object);
     202                    }
     203                }
     204
    178205                return (*this);
    179206            }
     
    215242            LanguageEntryLabel         description_;                //!< The description
    216243            ConfigValueCallbackBase*   callback_;                   //!< A callback function to call after getValue if the value changed
     244
     245            bool                       bContainerIsNew_;            //!< True if it's the first time getValue() gets called
     246            bool                       bDoInitialCallback_;         //!< True if the callback should be called as soon as it gets created
    217247    };
    218248}
Note: See TracChangeset for help on using the changeset viewer.