Просмотр исходного кода

Fixed formatting of what() exception message.

Sascha Zelzer лет назад: 12
Родитель
Сommit
efe1e7e358
2 измененных файлов с 9 добавлено и 6 удалено
  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,