diff --git a/src/app/dialogs/app/dialogaboutapp.cpp b/src/app/dialogs/app/dialogaboutapp.cpp index 317242837..aa9b69050 100644 --- a/src/app/dialogs/app/dialogaboutapp.cpp +++ b/src/app/dialogs/app/dialogaboutapp.cpp @@ -29,6 +29,7 @@ #include "dialogaboutapp.h" #include "ui_dialogaboutapp.h" #include "../../version.h" +#include #include #include diff --git a/src/app/exception/vexception.cpp b/src/app/exception/vexception.cpp index 0e475809a..e5d63c59c 100644 --- a/src/app/exception/vexception.cpp +++ b/src/app/exception/vexception.cpp @@ -30,6 +30,8 @@ #include #include #include +#include "../options.h" +#include //--------------------------------------------------------------------------------------------------------------------- /** @@ -80,7 +82,7 @@ void VException::CriticalMessageBox(const QString &situation, QWidget * parent) msgBox.setIcon(QMessageBox::Critical); QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QGridLayout* layout = static_cast(msgBox.layout()); - Q_CHECK_PTR(layout); + SCASSERT(layout != nullptr); layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); //Disable Qt::WaitCursor for error message. #ifndef QT_NO_CURSOR diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp index 1b14a3118..ef7805b7c 100644 --- a/src/app/geometry/varc.cpp +++ b/src/app/geometry/varc.cpp @@ -30,6 +30,7 @@ #include "vspline.h" #include "../exception/vexception.h" #include +#include class QRectF; diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp index 20af4ba4e..1289ad14b 100644 --- a/src/app/geometry/vspline.cpp +++ b/src/app/geometry/vspline.cpp @@ -29,6 +29,7 @@ #include "vspline.h" #include #include +#include //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/options.h b/src/app/options.h index 7bcd53bc1..53cdb7c61 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -33,6 +33,11 @@ #include #include #include +#include + +#ifdef Q_OS_WIN32 +#include +#endif /*Q_OS_WIN32*/ #define SceneSize 50000 @@ -283,4 +288,59 @@ extern const QString cm_Oprt; extern const QString mm_Oprt; extern const QString in_Oprt; +/* + * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow + * you to continue afterwards should you choose to. + * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 + * Usefull links: + * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - + * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func + * + * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx + * + * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx + * + * 4. Continue to debug after failed assertion on Linux? [C/C++] - + * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c + */ +#ifndef QT_NO_DEBUG +#ifdef Q_OS_WIN32 +#ifdef Q_CC_MSVC +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __FUNCSIG__, __FILE__, __LINE__); \ + DebugBreak(); \ + } \ +} \ + +#else + +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + DebugBreak(); \ + } \ +} \ + +#endif /*Q_CC_MSVC*/ +#else +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + std::raise(SIGTRAP); \ + } \ +} \ + +#endif /* Q_OS_WIN32 */ +#endif /* QT_NO_DEBUG */ + #endif // OPTIONS_H diff --git a/src/app/stable.h b/src/app/stable.h index 5b75d92fd..22bf1261b 100644 --- a/src/app/stable.h +++ b/src/app/stable.h @@ -43,37 +43,40 @@ #endif #ifdef QT_CORE_LIB -#include +# include #endif #ifdef QT_GUI_LIB -#include +# include #endif #ifdef QT_WIDGETS_LIB -#include +# include #endif #ifdef QT_XML_LIB -#include +# include #endif #ifdef QT_SVG_LIB -#include +# include #endif #ifdef QT_PRINTSUPPORT_LIB -#include +# include #endif -#ifdef QT_XMLPATTERNS_LIB -#include -#endif +//Build doesn't work, if include this headers on Windows. +#ifndef Q_OS_WIN +# ifdef QT_XMLPATTERNS_LIB +# include +# endif -#ifdef QT_NETWORK_LIB -#include -#endif +# ifdef QT_NETWORK_LIB +# include +# endif +#endif /*Q_OS_WIN*/ -#endif +#endif /*__cplusplus*/ #endif // STABLE_H diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h index e665ba67f..842ca5bc7 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -33,6 +33,7 @@ #include #include +#include #include "../../dialogs/tools/dialogtool.h" /** @@ -87,8 +88,8 @@ protected: */ void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true) { - Q_CHECK_PTR(tool); - Q_CHECK_PTR(event); + SCASSERT(tool != nullptr); + SCASSERT(event != nullptr); if (ignoreContextMenuEvent == false) { QMenu menu; @@ -144,7 +145,7 @@ protected: */ void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable) { - Q_CHECK_PTR(item); + SCASSERT(item != nullptr); if (id == item->id) { if (enable == false) diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index c5d2dfa1c..f165a5165 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -32,6 +32,7 @@ #include #include #include +#include const QString VToolDetail::TagName = QStringLiteral("detail"); const QString VToolDetail::TagNode = QStringLiteral("node"); @@ -99,9 +100,9 @@ VToolDetail::~VToolDetail() //--------------------------------------------------------------------------------------------------------------------- void VToolDetail::setDialog() { - Q_CHECK_PTR(dialog); + SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast(dialog); - Q_CHECK_PTR(dialogTool); + SCASSERT(dialogTool != nullptr); VDetail detail = VAbstractTool::data.GetDetail(id); dialogTool->setDetails(detail); } @@ -109,9 +110,9 @@ void VToolDetail::setDialog() //--------------------------------------------------------------------------------------------------------------------- void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { - Q_CHECK_PTR(dialog); + SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast(dialog); - Q_CHECK_PTR(dialogTool); + SCASSERT(dialogTool != nullptr); VDetail detail = dialogTool->getDetails(); VDetail det; for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) @@ -202,9 +203,9 @@ void VToolDetail::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - Q_CHECK_PTR(dialog); + SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast(dialog); - Q_CHECK_PTR(dialogTool); + SCASSERT(dialogTool != nullptr); VDetail det = dialogTool->getDetails(); doc->SetAttribute(domElement, AttrName, det.getName()); doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); @@ -433,9 +434,9 @@ template void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) { QHash* tools = doc->getTools(); - Q_CHECK_PTR(tools); + SCASSERT(tools != nullptr); Tool *tool = qobject_cast(tools->value(node.getId())); - Q_CHECK_PTR(tool); + SCASSERT(tool != nullptr); connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); tool->setParentItem(this); } diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index 36a246d13..8eadb791d 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -39,6 +39,7 @@ #include #include +#include const qreal VApplication::PrintDPI = 96.0; diff --git a/src/app/widgets/vsimplespline.cpp b/src/app/widgets/vsimplespline.cpp index 9f30b30f5..bc53d4e22 100644 --- a/src/app/widgets/vsimplespline.cpp +++ b/src/app/widgets/vsimplespline.cpp @@ -28,6 +28,7 @@ #include "vsimplespline.h" #include "../widgets/vapplication.h" +#include #include //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 6354c8b03..cbfd20c94 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -23,6 +23,7 @@ #include "qmuparserbase.h" #include #include +#include #ifdef QMUP_USE_OPENMP #include #endif @@ -2086,4 +2087,17 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const } #endif } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Set a function that can create variable pointer for unknown expression variables. + * @param a_pFactory A pointer to the variable factory. + * @param pUserData A user defined context pointer. + */ +// cppcheck-suppress unusedFunction +void qmu::QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData) +{ + m_pTokenReader->SetVarCreator(a_pFactory, pUserData); +} + } // namespace qmu diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h index b82954f9a..c7727426b 100644 --- a/src/libs/qmuparser/qmuparserbase.h +++ b/src/libs/qmuparser/qmuparserbase.h @@ -284,18 +284,6 @@ inline void QmuParserBase::AddValIdent(identfun_type a_pCallback) m_pTokenReader->AddValIdent(a_pCallback); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief Set a function that can create variable pointer for unknown expression variables. - * @param a_pFactory A pointer to the variable factory. - * @param pUserData A user defined context pointer. - */ -// cppcheck-suppress unusedFunction -inline void QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData) -{ - m_pTokenReader->SetVarCreator(a_pFactory, pUserData); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief Get the default symbols used for the built in operators. @@ -306,11 +294,13 @@ inline const QStringList &QmuParserBase::GetOprtDef() return c_DefaultOprt; } +//--------------------------------------------------------------------------------------------------------------------- inline QMap QmuParserBase::GetTokens() const { return m_Tokens; } +//--------------------------------------------------------------------------------------------------------------------- inline QMap QmuParserBase::GetNumbers() const { return m_Numbers; diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index e4f27746e..3634612eb 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -22,11 +22,10 @@ #include "qmuparserbytecode.h" -#include -#include -#include -#include +#include #include +#include +#include #include "qmuparserdef.h" #include "qmuparsererror.h" diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 7b1d596c0..49b16e972 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -26,6 +26,7 @@ #include "qmuparser_global.h" #include #include +#include #include "qmuparserdef.h" diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index a152d5d75..bbcf768bf 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -24,6 +24,7 @@ #include "qmuparserbase.h" #include +#include /** * @file