Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
QDebug instantiation can be heavy
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Oct 7, 2014
1 parent 0a8ce73 commit a871765
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
13 changes: 2 additions & 11 deletions include/qtaround/error.hpp
Expand Up @@ -28,22 +28,13 @@ class Error : public std::exception
public:
Error(QVariantMap const &from) : m(from) {}
virtual ~Error() noexcept(true) {}
virtual const char* what() const noexcept(true)
{
if (s.isEmpty())
s = dump(m);
return s.toUtf8();
}
virtual const char* what() const noexcept(true);

QVariantMap m;
mutable QString s;
};

static inline QDebug operator << (QDebug dst, error::Error const &src)
{
dst << src.m;
return dst;
}
QDebug operator << (QDebug dst, error::Error const &src);

static inline void raise(QVariantMap const &m)
{
Expand Down
21 changes: 19 additions & 2 deletions src/util.cpp
@@ -1,7 +1,6 @@
/**
* @file util.cpp
* @brief Misc. helpful utilities
* @author Denis Zalevskiy <denis.zalevskiy@jolla.com>
* @copyright (C) 2014 Jolla Ltd.
* @par License: LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*/
Expand All @@ -12,7 +11,25 @@
#include <QString>
#include <QMap>

namespace qtaround { namespace util {
namespace qtaround {

namespace error {
const char* Error::what() const noexcept(true)
{
if (s.isEmpty())
s = dump(m);
return s.toUtf8();
}

QDebug operator << (QDebug dst, error::Error const &src)
{
dst << src.m;
return dst;
}

}

namespace util {

namespace {

Expand Down

0 comments on commit a871765

Please sign in to comment.