Use pointers to scenes.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-05 14:46:12 +03:00
parent c03464144e
commit b646a11bc0
3 changed files with 11 additions and 23 deletions

View File

@ -1886,7 +1886,7 @@ void MainWindow::LoadPattern(const QString &fileName)
try
{
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
doc->Parse(Document::FullParse);
}
catch (const VExceptionObjectError &e)
{

View File

@ -240,14 +240,14 @@ bool VPattern::SetNameDraw(const QString &name)
* @param sceneDraw pointer to draw scene.
* @param sceneDetail pointer to details scene.
*/
void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail)
void VPattern::Parse(const Document::Documents &parse)
{
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
Q_CHECK_PTR(sceneDraw);
Q_CHECK_PTR(sceneDetail);
PrepareForParse(parse, sceneDraw, sceneDetail);
SCASSERT(sceneDraw != nullptr);
SCASSERT(sceneDetail != nullptr);
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)
{
@ -661,50 +661,42 @@ bool VPattern::SaveDocument(const QString &fileName)
*/
void VPattern::LiteParseTree()
{
VMainGraphicsScene *scene = nullptr;
try
{
scene = new VMainGraphicsScene();
Parse(Document::LiteParse, scene, scene);
Parse(Document::LiteParse);
}
catch (const VExceptionObjectError &e)
{
delete scene;
e.CriticalMessageBox(tr("Error parsing file."));
emit ClearMainWindow();
return;
}
catch (const VExceptionConversionError &e)
{
delete scene;
e.CriticalMessageBox(tr("Error can't convert value."));
emit ClearMainWindow();
return;
}
catch (const VExceptionEmptyParameter &e)
{
delete scene;
e.CriticalMessageBox(tr("Error empty parameter."));
emit ClearMainWindow();
return;
}
catch (const VExceptionWrongId &e)
{
delete scene;
e.CriticalMessageBox(tr("Error wrong id."));
emit ClearMainWindow();
return;
}
catch (VException &e)
{
delete scene;
e.CriticalMessageBox(tr("Error parsing file."));
emit ClearMainWindow();
return;
}
catch (const std::bad_alloc &)
{
delete scene;
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
@ -723,7 +715,6 @@ void VPattern::LiteParseTree()
return;
}
delete scene;
setCurrentData();
emit FullUpdateFromFile();
}
@ -1834,11 +1825,10 @@ void VPattern::CollectId(const QDomElement &node, QVector<quint32> &vector) cons
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail)
void VPattern::PrepareForParse(const Document::Documents &parse)
{
Q_CHECK_PTR(sceneDraw);
Q_CHECK_PTR(sceneDetail);
SCASSERT(sceneDraw != nullptr);
SCASSERT(sceneDetail != nullptr);
if (parse == Document::FullParse)
{
TestUniqueId();

View File

@ -70,8 +70,7 @@ public:
bool GetActivDrawElement(QDomElement &element) const;
bool appendDraw(const QString& name);
bool SetNameDraw(const QString& name);
void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail);
void Parse(const Document::Documents &parse);
QHash<quint32, VDataTool*>* getTools();
VDataTool* getTool(const quint32 &id);
QVector<VToolRecord> *getHistory();
@ -203,8 +202,7 @@ private:
void ParseIncrementsElement(const QDomNode& node);
quint32 GetParametrId(const QDomElement& domElement) const;
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
void PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail);
void PrepareForParse(const Document::Documents &parse);
void UpdateMeasurements();
};