mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 03:09:53 +02:00
Red error, ensure residual actiondata is not read for RichLabel
This commit is contained in:
@@ -58,7 +58,8 @@ extern "C"
|
|||||||
Client::Client():
|
Client::Client():
|
||||||
authUser(0, ""),
|
authUser(0, ""),
|
||||||
updateAvailable(false),
|
updateAvailable(false),
|
||||||
versionCheckRequest(NULL)
|
versionCheckRequest(NULL),
|
||||||
|
messageOfTheDay("")
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i = 0; i < THUMB_CACHE_SIZE; i++)
|
for(i = 0; i < THUMB_CACHE_SIZE; i++)
|
||||||
|
@@ -22,7 +22,8 @@ public:
|
|||||||
|
|
||||||
RichLabel::RichLabel(Point position, Point size, std::string labelText):
|
RichLabel::RichLabel(Point position, Point size, std::string labelText):
|
||||||
Component(position, size),
|
Component(position, size),
|
||||||
textSource(labelText)
|
textSource(labelText),
|
||||||
|
displayText("")
|
||||||
{
|
{
|
||||||
updateRichText();
|
updateRichText();
|
||||||
}
|
}
|
||||||
@@ -35,15 +36,21 @@ RichLabel::~RichLabel()
|
|||||||
void RichLabel::updateRichText()
|
void RichLabel::updateRichText()
|
||||||
{
|
{
|
||||||
regions.clear();
|
regions.clear();
|
||||||
|
displayText = "";
|
||||||
|
|
||||||
|
if(textSource.length())
|
||||||
|
{
|
||||||
|
|
||||||
enum State { ReadText, ReadData, ReadRegion, ReadDataStart };
|
enum State { ReadText, ReadData, ReadRegion, ReadDataStart };
|
||||||
State state = ReadText;
|
State state = ReadText;
|
||||||
|
|
||||||
int currentDataPos = 0;
|
int currentDataPos = 0;
|
||||||
char * currentData = new char[textSource.length()+1];
|
char * currentData = new char[textSource.length()+1];
|
||||||
|
std::fill(currentData, currentData+textSource.length()+1, 0);
|
||||||
|
|
||||||
int finalTextPos = 0;
|
int finalTextPos = 0;
|
||||||
char * finalText = new char[textSource.length()+1];
|
char * finalText = new char[textSource.length()+1];
|
||||||
|
std::fill(finalText, finalText+textSource.length()+1, 0);
|
||||||
|
|
||||||
int originalTextPos = 0;
|
int originalTextPos = 0;
|
||||||
char * originalText = new char[textSource.length()+1];
|
char * originalText = new char[textSource.length()+1];
|
||||||
@@ -86,6 +93,7 @@ void RichLabel::updateRichText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
finalText[finalTextPos++] = current;
|
finalText[finalTextPos++] = current;
|
||||||
|
finalText[finalTextPos] = 0;
|
||||||
if(stackPos >= 0)
|
if(stackPos >= 0)
|
||||||
{
|
{
|
||||||
regionsStack[stackPos].finish = finalTextPos;
|
regionsStack[stackPos].finish = finalTextPos;
|
||||||
@@ -101,6 +109,7 @@ void RichLabel::updateRichText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentData[currentDataPos++] = current;
|
currentData[currentDataPos++] = current;
|
||||||
|
currentData[currentDataPos] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(state == ReadDataStart)
|
else if(state == ReadDataStart)
|
||||||
@@ -136,13 +145,14 @@ void RichLabel::updateRichText()
|
|||||||
}
|
}
|
||||||
catch (const RichTextParseException & e)
|
catch (const RichTextParseException & e)
|
||||||
{
|
{
|
||||||
displayText = "[Parse exception: " + std::string(e.what()) + "]";
|
displayText = "\br[Parse exception: " + std::string(e.what()) + "]";
|
||||||
|
regions.clear();
|
||||||
}
|
}
|
||||||
delete[] currentData;
|
delete[] currentData;
|
||||||
delete[] finalText;
|
delete[] finalText;
|
||||||
delete[] originalText;
|
delete[] originalText;
|
||||||
delete[] regionsStack;
|
delete[] regionsStack;
|
||||||
|
}
|
||||||
TextPosition(displayText);
|
TextPosition(displayText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user