Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11106 for code/trunk


Ignore:
Timestamp:
Feb 3, 2016, 1:02:33 PM (9 years ago)
Author:
muemart
Message:

Fix a memory leak. Also fix some potentially invalid references to vector elements after the vector resized.

Location:
code/trunk/src/libraries/core/input
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/input/KeyBinder.cc

    r11083 r11106  
    324324        Return the first key name for a specific command
    325325    */
    326     const std::string& KeyBinder::getBinding(const std::string& commandName)
     326    std::string KeyBinder::getBinding(const std::string& commandName)
    327327    {
    328328        if (this->allCommands_.find(commandName) != this->allCommands_.end())
     
    343343        The index at which the key name is returned for.
    344344    */
    345     const std::string& KeyBinder::getBinding(const std::string& commandName, unsigned int index)
     345    std::string KeyBinder::getBinding(const std::string& commandName, unsigned int index)
    346346    {
    347347        if (this->allCommands_.find(commandName) != this->allCommands_.end())
     
    361361        Return the first key name for a specific command in a human readable form
    362362    */
    363     const std::string& KeyBinder::getBindingReadable(const std::string& commandName)
    364     {
    365         const std::string& binding = this->getBinding(commandName);
     363    std::string KeyBinder::getBindingReadable(const std::string& commandName)
     364    {
     365        std::string binding = this->getBinding(commandName);
    366366
    367367        SubString substring = SubString(binding, ".");
     
    394394            return binding;
    395395
    396         return *(new std::string(stream.str()));
     396        binding = stream.str();
     397        return binding;
    397398    }
    398399
  • code/trunk/src/libraries/core/input/KeyBinder.h

    r11071 r11106  
    6666        void clearBindings();
    6767        bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
    68         const std::string& getBinding(const std::string& commandName); //tolua_export
    69         const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export
    70         const std::string& getBindingReadable(const std::string& commandName); //tolua_export
     68        std::string getBinding(const std::string& commandName); //tolua_export
     69        std::string getBinding(const std::string& commandName, unsigned int index); //tolua_export
     70        std::string getBindingReadable(const std::string& commandName); //tolua_export
    7171        unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export
    7272
Note: See TracChangeset for help on using the changeset viewer.