made _BInlineInput_::AddClause() more robust in low memory conditions
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20870 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7a93cf5a82
commit
0d4fbcc8fe
@ -4427,7 +4427,8 @@ BTextView::HandleInputMethodChanged(BMessage *message)
|
||||
int32 clauseEnd;
|
||||
while (message->FindInt32("be:clause_start", clauseCount, &clauseStart) == B_OK &&
|
||||
message->FindInt32("be:clause_end", clauseCount, &clauseEnd) == B_OK) {
|
||||
fInline->AddClause(clauseStart, clauseEnd);
|
||||
if (!fInline->AddClause(clauseStart, clauseEnd))
|
||||
break;
|
||||
clauseCount++;
|
||||
}
|
||||
|
||||
|
@ -153,12 +153,18 @@ _BInlineInput_::SetSelectionOffset(int32 offset)
|
||||
\param start The offset into the string where the clause starts.
|
||||
\param end The offset into the string where the clause finishes.
|
||||
*/
|
||||
void
|
||||
bool
|
||||
_BInlineInput_::AddClause(int32 start, int32 end)
|
||||
{
|
||||
fClauses = (clause *)realloc(fClauses, ++fNumClauses * sizeof(clause));
|
||||
fClauses[fNumClauses - 1].start = start;
|
||||
fClauses[fNumClauses - 1].end = end;
|
||||
void *newData = realloc(fClauses, (fNumClauses + 1) * sizeof(clause));
|
||||
if (newData == NULL)
|
||||
return false;
|
||||
|
||||
fClauses = (clause *)newData;
|
||||
fClauses[fNumClauses].start = start;
|
||||
fClauses[fNumClauses].end = end;
|
||||
fNumClauses++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
int32 SelectionOffset() const;
|
||||
void SetSelectionOffset(int32 offset);
|
||||
|
||||
void AddClause(int32, int32);
|
||||
bool AddClause(int32, int32);
|
||||
bool GetClause(int32 index, int32 *start, int32 *end) const;
|
||||
int32 CountClauses() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user