mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 02:45:38 +00:00
fixed local variable caching issue in automatic error checking (Fixes #2927)
(cherry picked from commit 7bef97bf33
)
This commit is contained in:
parent
14708e181c
commit
69e6328507
6 changed files with 55 additions and 3 deletions
|
@ -39,8 +39,6 @@ char CSMWorld::ScriptContext::getGlobalType (const std::string& name) const
|
||||||
std::pair<char, bool> CSMWorld::ScriptContext::getMemberType (const std::string& name,
|
std::pair<char, bool> CSMWorld::ScriptContext::getMemberType (const std::string& name,
|
||||||
const std::string& id) const
|
const std::string& id) const
|
||||||
{
|
{
|
||||||
/// \todo invalidate locals cache on change to scripts
|
|
||||||
|
|
||||||
std::string id2 = Misc::StringUtils::lowerCase (id);
|
std::string id2 = Misc::StringUtils::lowerCase (id);
|
||||||
|
|
||||||
int index = mData.getScripts().searchId (id2);
|
int index = mData.getScripts().searchId (id2);
|
||||||
|
@ -120,3 +118,18 @@ void CSMWorld::ScriptContext::clear()
|
||||||
mIdsUpdated = false;
|
mIdsUpdated = false;
|
||||||
mLocals.clear();
|
mLocals.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSMWorld::ScriptContext::clearLocals (const std::string& script)
|
||||||
|
{
|
||||||
|
std::map<std::string, Compiler::Locals>::iterator iter =
|
||||||
|
mLocals.find (Misc::StringUtils::lowerCase (script));
|
||||||
|
|
||||||
|
if (iter!=mLocals.end())
|
||||||
|
{
|
||||||
|
mLocals.erase (iter);
|
||||||
|
mIdsUpdated = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ namespace CSMWorld
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
///< Remove all cached data.
|
///< Remove all cached data.
|
||||||
|
|
||||||
|
/// \return Were there any locals that needed clearing?
|
||||||
|
bool clearLocals (const std::string& script);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,11 @@ void CSVWorld::ScriptErrorTable::clear()
|
||||||
setRowCount (0);
|
setRowCount (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSVWorld::ScriptErrorTable::clearLocals (const std::string& script)
|
||||||
|
{
|
||||||
|
return mContext.clearLocals (script);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
||||||
{
|
{
|
||||||
if (item (row, 1))
|
if (item (row, 1))
|
||||||
|
|
|
@ -44,6 +44,11 @@ namespace CSVWorld
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
/// Clear local variable cache for \a script.
|
||||||
|
///
|
||||||
|
/// \return Were there any locals that needed clearing?
|
||||||
|
bool clearLocals (const std::string& script);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void cellClicked (int row, int column);
|
void cellClicked (int row, int column);
|
||||||
|
|
|
@ -89,6 +89,7 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Scripts));
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Scripts));
|
||||||
|
|
||||||
mColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_ScriptText);
|
mColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_ScriptText);
|
||||||
|
mIdColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Id);
|
||||||
mStateColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
|
mStateColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
|
||||||
|
|
||||||
QString source = mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString();
|
QString source = mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString();
|
||||||
|
@ -241,6 +242,15 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo
|
||||||
|
|
||||||
ScriptEdit::ChangeLock lock (*mEditor);
|
ScriptEdit::ChangeLock lock (*mEditor);
|
||||||
|
|
||||||
|
bool updateRequired = false;
|
||||||
|
|
||||||
|
for (int i=topLeft.row(); i<=bottomRight.row(); ++i)
|
||||||
|
{
|
||||||
|
std::string id = mModel->data (mModel->index (i, mIdColumn)).toString().toUtf8().constData();
|
||||||
|
if (mErrors->clearLocals (id))
|
||||||
|
updateRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
|
||||||
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row())
|
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row())
|
||||||
|
@ -256,13 +266,28 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo
|
||||||
mEditor->setPlainText (source);
|
mEditor->setPlainText (source);
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
|
|
||||||
recompile();
|
updateRequired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateRequired)
|
||||||
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end)
|
void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
|
bool updateRequired = false;
|
||||||
|
|
||||||
|
for (int i=start; i<=end; ++i)
|
||||||
|
{
|
||||||
|
std::string id = mModel->data (mModel->index (i, mIdColumn)).toString().toUtf8().constData();
|
||||||
|
if (mErrors->clearLocals (id))
|
||||||
|
updateRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateRequired)
|
||||||
|
recompile();
|
||||||
|
|
||||||
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
|
||||||
if (!parent.isValid() && index.row()>=start && index.row()<=end)
|
if (!parent.isValid() && index.row()>=start && index.row()<=end)
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace CSVWorld
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
CSMWorld::IdTable *mModel;
|
CSMWorld::IdTable *mModel;
|
||||||
int mColumn;
|
int mColumn;
|
||||||
|
int mIdColumn;
|
||||||
int mStateColumn;
|
int mStateColumn;
|
||||||
TableBottomBox *mBottom;
|
TableBottomBox *mBottom;
|
||||||
RecordButtonBar *mButtons;
|
RecordButtonBar *mButtons;
|
||||||
|
|
Loading…
Reference in a new issue