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 "ui_dialogaboutapp.h"
#include "../../version.h"
#include <QDate>
#include <QDesktopServices>
#include <QMessageBox>

View File

@ -30,6 +30,8 @@
#include <QMessageBox>
#include <QSpacerItem>
#include <QGridLayout>
#include "../options.h"
#include <QApplication>
//---------------------------------------------------------------------------------------------------------------------
/**
@ -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<QGridLayout*>(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

View File

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

View File

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

View File

@ -33,6 +33,11 @@
#include <QString>
#include <QMetaType>
#include <QtGlobal>
#include <csignal>
#ifdef Q_OS_WIN32
#include <Windows.h>
#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

View File

@ -66,6 +66,8 @@
# include <QtPrintSupport>
#endif
//Build doesn't work, if include this headers on Windows.
#ifndef Q_OS_WIN
# ifdef QT_XMLPATTERNS_LIB
# include <QtXmlPatterns>
# endif
@ -73,7 +75,8 @@
# ifdef QT_NETWORK_LIB
# include <QtNetwork>
# endif
#endif /*Q_OS_WIN*/
#endif
#endif /*__cplusplus*/
#endif // STABLE_H

View File

@ -33,6 +33,7 @@
#include <QMenu>
#include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsView>
#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)

View File

@ -32,6 +32,7 @@
#include <QKeyEvent>
#include <QGraphicsSceneMouseEvent>
#include <QMenu>
#include <QGraphicsView>
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<DialogDetail*>(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<DialogDetail*>(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<DialogDetail*>(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 <typename Tool>
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
{
QHash<quint32, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
SCASSERT(tools != nullptr);
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
Q_CHECK_PTR(tool);
SCASSERT(tool != nullptr);
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
tool->setParentItem(this);
}

View File

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

View File

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

View File

@ -23,6 +23,7 @@
#include "qmuparserbase.h"
#include <QTextStream>
#include <QtMath>
#include <QDebug>
#ifdef QMUP_USE_OPENMP
#include <omp.h>
#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

View File

@ -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<int, QString> QmuParserBase::GetTokens() const
{
return m_Tokens;
}
//---------------------------------------------------------------------------------------------------------------------
inline QMap<int, QString> QmuParserBase::GetNumbers() const
{
return m_Numbers;

View File

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

View File

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

View File

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