Explorar o código

Fixed formatting of what() exception message.

Sascha Zelzer %!s(int64=12) %!d(string=hai) anos
pai
achega
efe1e7e358
Modificáronse 2 ficheiros con 9 adicións e 6 borrados
  1. 8 6
      Libs/Core/ctkException.cpp
  2. 1 0
      Libs/Core/ctkException.h

+ 8 - 6
Libs/Core/ctkException.cpp

@@ -105,14 +105,16 @@ const char* ctkException::className() const throw()
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
 const char* ctkException::what() const throw()
 const char* ctkException::what() const throw()
 {
 {
-  static std::string txt;
-  txt = std::string(name());
-  if (!Msg.isEmpty())
+  if (WhatMsg.empty())
   {
   {
-    txt += ": ";
-    txt += Msg.toStdString();
+    WhatMsg = std::string(name());
+    if (!Msg.isEmpty())
+    {
+      WhatMsg += ": ";
+      WhatMsg += Msg.toStdString();
+    }
   }
   }
-  return txt.c_str();
+  return WhatMsg.c_str();
 }
 }
 
 
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------

+ 1 - 0
Libs/Core/ctkException.h

@@ -163,6 +163,7 @@ protected:
 private:
 private:
 
 
   QString Msg;
   QString Msg;
+  mutable std::string WhatMsg;
   ctkException* NestedException;
   ctkException* NestedException;
 
 
   void printEnclosedStackTrace(QDebug dbg, const QList<QString>& enclosingTrace,
   void printEnclosedStackTrace(QDebug dbg, const QList<QString>& enclosingTrace,