Backport changeset 8a2e2ab97237.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-03 15:15:17 +03:00
parent 20cedcc9a1
commit a40099da1f
15 changed files with 118 additions and 41 deletions

View File

@ -29,6 +29,7 @@
#include "dialogaboutapp.h" #include "dialogaboutapp.h"
#include "ui_dialogaboutapp.h" #include "ui_dialogaboutapp.h"
#include "../../version.h" #include "../../version.h"
#include <QDate>
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>

View File

@ -30,6 +30,8 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSpacerItem> #include <QSpacerItem>
#include <QGridLayout> #include <QGridLayout>
#include "../options.h"
#include <QApplication>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -80,7 +82,7 @@ void VException::CriticalMessageBox(const QString &situation, QWidget * parent)
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout* layout = static_cast<QGridLayout*>(msgBox.layout()); QGridLayout* layout = static_cast<QGridLayout*>(msgBox.layout());
Q_CHECK_PTR(layout); SCASSERT(layout != nullptr);
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
//Disable Qt::WaitCursor for error message. //Disable Qt::WaitCursor for error message.
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR

View File

@ -30,6 +30,7 @@
#include "vspline.h" #include "vspline.h"
#include "../exception/vexception.h" #include "../exception/vexception.h"
#include <QDebug> #include <QDebug>
#include <QtMath>
class QRectF; class QRectF;

View File

@ -29,6 +29,7 @@
#include "vspline.h" #include "vspline.h"
#include <cmath> #include <cmath>
#include <QDebug> #include <QDebug>
#include <QtMath>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View File

@ -33,6 +33,11 @@
#include <QString> #include <QString>
#include <QMetaType> #include <QMetaType>
#include <QtGlobal> #include <QtGlobal>
#include <csignal>
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif /*Q_OS_WIN32*/
#define SceneSize 50000 #define SceneSize 50000
@ -283,4 +288,59 @@ extern const QString cm_Oprt;
extern const QString mm_Oprt; extern const QString mm_Oprt;
extern const QString in_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 #endif // OPTIONS_H

View File

@ -43,37 +43,40 @@
#endif #endif
#ifdef QT_CORE_LIB #ifdef QT_CORE_LIB
#include <QtCore> # include <QtCore>
#endif #endif
#ifdef QT_GUI_LIB #ifdef QT_GUI_LIB
#include <QtGui> # include <QtGui>
#endif #endif
#ifdef QT_WIDGETS_LIB #ifdef QT_WIDGETS_LIB
#include <QtWidgets> # include <QtWidgets>
#endif #endif
#ifdef QT_XML_LIB #ifdef QT_XML_LIB
#include <QtXml> # include <QtXml>
#endif #endif
#ifdef QT_SVG_LIB #ifdef QT_SVG_LIB
#include <QtSvg/QtSvg> # include <QtSvg/QtSvg>
#endif #endif
#ifdef QT_PRINTSUPPORT_LIB #ifdef QT_PRINTSUPPORT_LIB
#include <QtPrintSupport> # include <QtPrintSupport>
#endif #endif
#ifdef QT_XMLPATTERNS_LIB //Build doesn't work, if include this headers on Windows.
#include <QtXmlPatterns> #ifndef Q_OS_WIN
#endif # ifdef QT_XMLPATTERNS_LIB
# include <QtXmlPatterns>
# endif
#ifdef QT_NETWORK_LIB # ifdef QT_NETWORK_LIB
#include <QtNetwork> # include <QtNetwork>
#endif # endif
#endif /*Q_OS_WIN*/
#endif #endif /*__cplusplus*/
#endif // STABLE_H #endif // STABLE_H

View File

@ -33,6 +33,7 @@
#include <QMenu> #include <QMenu>
#include <QGraphicsSceneContextMenuEvent> #include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsView>
#include "../../dialogs/tools/dialogtool.h" #include "../../dialogs/tools/dialogtool.h"
/** /**
@ -87,8 +88,8 @@ protected:
*/ */
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true) void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true)
{ {
Q_CHECK_PTR(tool); SCASSERT(tool != nullptr);
Q_CHECK_PTR(event); SCASSERT(event != nullptr);
if (ignoreContextMenuEvent == false) if (ignoreContextMenuEvent == false)
{ {
QMenu menu; QMenu menu;
@ -144,7 +145,7 @@ protected:
*/ */
void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable) void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable)
{ {
Q_CHECK_PTR(item); SCASSERT(item != nullptr);
if (id == item->id) if (id == item->id)
{ {
if (enable == false) if (enable == false)

View File

@ -32,6 +32,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QMenu> #include <QMenu>
#include <QGraphicsView>
const QString VToolDetail::TagName = QStringLiteral("detail"); const QString VToolDetail::TagName = QStringLiteral("detail");
const QString VToolDetail::TagNode = QStringLiteral("node"); const QString VToolDetail::TagNode = QStringLiteral("node");
@ -99,9 +100,9 @@ VToolDetail::~VToolDetail()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDetail::setDialog() void VToolDetail::setDialog()
{ {
Q_CHECK_PTR(dialog); SCASSERT(dialog != nullptr);
DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog);
Q_CHECK_PTR(dialogTool); SCASSERT(dialogTool != nullptr);
VDetail detail = VAbstractTool::data.GetDetail(id); VDetail detail = VAbstractTool::data.GetDetail(id);
dialogTool->setDetails(detail); dialogTool->setDetails(detail);
} }
@ -109,9 +110,9 @@ void VToolDetail::setDialog()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{ {
Q_CHECK_PTR(dialog); SCASSERT(dialog != nullptr);
DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog);
Q_CHECK_PTR(dialogTool); SCASSERT(dialogTool != nullptr);
VDetail detail = dialogTool->getDetails(); VDetail detail = dialogTool->getDetails();
VDetail det; VDetail det;
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) 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)); QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement()) if (domElement.isElement())
{ {
Q_CHECK_PTR(dialog); SCASSERT(dialog != nullptr);
DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog);
Q_CHECK_PTR(dialogTool); SCASSERT(dialogTool != nullptr);
VDetail det = dialogTool->getDetails(); VDetail det = dialogTool->getDetails();
doc->SetAttribute(domElement, AttrName, det.getName()); doc->SetAttribute(domElement, AttrName, det.getName());
doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance()));
@ -433,9 +434,9 @@ template <typename Tool>
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
{ {
QHash<quint32, VDataTool*>* tools = doc->getTools(); QHash<quint32, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools); SCASSERT(tools != nullptr);
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId())); Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
Q_CHECK_PTR(tool); SCASSERT(tool != nullptr);
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
tool->setParentItem(this); tool->setParentItem(this);
} }

View File

@ -39,6 +39,7 @@
#include <QSettings> #include <QSettings>
#include <container/calculator.h> #include <container/calculator.h>
#include <QtMath>
const qreal VApplication::PrintDPI = 96.0; const qreal VApplication::PrintDPI = 96.0;

View File

@ -28,6 +28,7 @@
#include "vsimplespline.h" #include "vsimplespline.h"
#include "../widgets/vapplication.h" #include "../widgets/vapplication.h"
#include <QGraphicsSceneMouseEvent>
#include <QPen> #include <QPen>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,7 @@
#include "qmuparserbase.h" #include "qmuparserbase.h"
#include <QTextStream> #include <QTextStream>
#include <QtMath> #include <QtMath>
#include <QDebug>
#ifdef QMUP_USE_OPENMP #ifdef QMUP_USE_OPENMP
#include <omp.h> #include <omp.h>
#endif #endif
@ -2086,4 +2087,17 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
} }
#endif #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 } // namespace qmu

View File

@ -284,18 +284,6 @@ inline void QmuParserBase::AddValIdent(identfun_type a_pCallback)
m_pTokenReader->AddValIdent(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. * @brief Get the default symbols used for the built in operators.
@ -306,11 +294,13 @@ inline const QStringList &QmuParserBase::GetOprtDef()
return c_DefaultOprt; return c_DefaultOprt;
} }
//---------------------------------------------------------------------------------------------------------------------
inline QMap<int, QString> QmuParserBase::GetTokens() const inline QMap<int, QString> QmuParserBase::GetTokens() const
{ {
return m_Tokens; return m_Tokens;
} }
//---------------------------------------------------------------------------------------------------------------------
inline QMap<int, QString> QmuParserBase::GetNumbers() const inline QMap<int, QString> QmuParserBase::GetNumbers() const
{ {
return m_Numbers; return m_Numbers;

View File

@ -22,11 +22,10 @@
#include "qmuparserbytecode.h" #include "qmuparserbytecode.h"
#include <cassert> #include <QStack>
#include <string>
#include <stack>
#include <iostream>
#include <QString> #include <QString>
#include <QtMath>
#include <QDebug>
#include "qmuparserdef.h" #include "qmuparserdef.h"
#include "qmuparsererror.h" #include "qmuparsererror.h"

View File

@ -26,6 +26,7 @@
#include "qmuparser_global.h" #include "qmuparser_global.h"
#include <sstream> #include <sstream>
#include <QException> #include <QException>
#include <QVector>
#include "qmuparserdef.h" #include "qmuparserdef.h"

View File

@ -24,6 +24,7 @@
#include "qmuparserbase.h" #include "qmuparserbase.h"
#include <QStringList> #include <QStringList>
#include <QDebug>
/** /**
* @file * @file