Fix for bug #40392: Crash on exit from composer due to spellchecker init failure

Modified First/LastSelectedBlock() to check if a range is collapsed before
trying to iterate over it.

    editor/txtsvc/src/nsTextServicesDocument.cpp

r=jfrancis@netscape.com  a=beppe@netscape.com
This commit is contained in:
kin%netscape.com 2000-05-31 03:18:46 +00:00
Родитель 82849412ce
Коммит 2e76a9364c
2 изменённых файлов: 68 добавлений и 0 удалений

Просмотреть файл

@ -968,6 +968,23 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
result = range->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
if (isCollapsed)
{
// If we get here, the range is collapsed because there is nothing before
// the current selection! Just return NS_OK;
UNLOCK_DOC(this);
return NS_OK;
}
result = CreateContentIterator(range, getter_AddRefs(iter));
if (NS_FAILED(result))
@ -1458,6 +1475,23 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
result = range->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
if (isCollapsed)
{
// If we get here, the range is collapsed because there is nothing after
// the current selection! Just return NS_OK;
UNLOCK_DOC(this);
return NS_OK;
}
result = CreateContentIterator(range, getter_AddRefs(iter));
if (NS_FAILED(result))

Просмотреть файл

@ -968,6 +968,23 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
result = range->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
if (isCollapsed)
{
// If we get here, the range is collapsed because there is nothing before
// the current selection! Just return NS_OK;
UNLOCK_DOC(this);
return NS_OK;
}
result = CreateContentIterator(range, getter_AddRefs(iter));
if (NS_FAILED(result))
@ -1458,6 +1475,23 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
result = range->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
{
UNLOCK_DOC(this);
return result;
}
if (isCollapsed)
{
// If we get here, the range is collapsed because there is nothing after
// the current selection! Just return NS_OK;
UNLOCK_DOC(this);
return NS_OK;
}
result = CreateContentIterator(range, getter_AddRefs(iter));
if (NS_FAILED(result))