diff options
Diffstat (limited to 'lingucomponent/source/languageguessing')
-rw-r--r-- | lingucomponent/source/languageguessing/simpleguesser.cxx | 7 | ||||
-rw-r--r-- | lingucomponent/source/languageguessing/simpleguesser.hxx | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lingucomponent/source/languageguessing/simpleguesser.cxx b/lingucomponent/source/languageguessing/simpleguesser.cxx index 1162884ef45a..b6d52cdba4be 100644 --- a/lingucomponent/source/languageguessing/simpleguesser.cxx +++ b/lingucomponent/source/languageguessing/simpleguesser.cxx @@ -95,9 +95,14 @@ SimpleGuesser::SimpleGuesser() h = NULL; } -void SimpleGuesser::operator=(SimpleGuesser& sg){ +SimpleGuesser& SimpleGuesser::operator=(const SimpleGuesser& sg){ + // Check for self-assignment! + if (this == &sg) // Same object? + return *this; // Yes, so skip assignment, and just return *this. + if(h){textcat_Done(h);} h = sg.h; + return *this; } SimpleGuesser::~SimpleGuesser() diff --git a/lingucomponent/source/languageguessing/simpleguesser.hxx b/lingucomponent/source/languageguessing/simpleguesser.hxx index eed1af930f27..acf3ae30a550 100644 --- a/lingucomponent/source/languageguessing/simpleguesser.hxx +++ b/lingucomponent/source/languageguessing/simpleguesser.hxx @@ -37,10 +37,10 @@ public: /**inits the object with conf file "./conf.txt"*/ SimpleGuesser(); - /** Compares the current Simpleguesser with an other - * @param SimpleGuesser& sg the other guesser to compare + /** + * @param SimpleGuesser& sg the other guesser */ - void operator=(SimpleGuesser& sg); + SimpleGuesser& operator=(const SimpleGuesser& sg); /** * destroy the object |