Text editor still borked... cleaned it up a bit
This commit is contained in:
@@ -163,24 +163,27 @@ void HGFloaterTextEditor::assetCallback(LLVFS *vfs,
|
|||||||
LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
|
LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
|
||||||
S32 size = file.getSize();
|
S32 size = file.getSize();
|
||||||
|
|
||||||
char* buffer = new char[size];
|
std::string new_data("");
|
||||||
|
if(size > 0)
|
||||||
|
{
|
||||||
|
char* buffer = new char[size + 1];
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
{
|
{
|
||||||
llerrs << "Memory Allocation Failed" << llendl;
|
llerrs << "Memory Allocation Failed" << llendl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.read((U8*)buffer, size);
|
file.read((U8*)buffer, size);
|
||||||
|
buffer[size - 1] = 0;
|
||||||
|
|
||||||
std::string new_data;
|
new_data = std::string(buffer);
|
||||||
for(S32 i = 0; i < size; i++)
|
delete[] buffer;
|
||||||
new_data += (char)buffer[i];
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
floater->mEditor->setValue((LLSD)new_data);
|
floater->mEditor->setText(LLStringExplicit(new_data));
|
||||||
floater->mEditor->setVisible(TRUE);
|
floater->mEditor->setVisible(TRUE);
|
||||||
floater->childSetText("status_text", std::string(""));
|
floater->childSetText("status_text", llformat("File Size: %d", size));
|
||||||
|
|
||||||
floater->childSetEnabled("upload_btn", true);
|
floater->childSetEnabled("upload_btn", true);
|
||||||
floater->childSetEnabled("save_btn", false);
|
floater->childSetEnabled("save_btn", false);
|
||||||
@@ -251,7 +254,6 @@ void HGFloaterTextEditor::onClickUpload(void* user_data)
|
|||||||
LLNotifications::instance().add("ErrorMessage", args);
|
LLNotifications::instance().add("ErrorMessage", args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
LLAssetStorage::LLStoreAssetCallback callback = NULL;
|
LLAssetStorage::LLStoreAssetCallback callback = NULL;
|
||||||
void *fake_user_data = NULL;
|
void *fake_user_data = NULL;
|
||||||
@@ -326,8 +328,6 @@ void HGFloaterTextEditor::onClickSave(void* user_data)
|
|||||||
LLNotifications::instance().add("ErrorMessage", args);
|
LLNotifications::instance().add("ErrorMessage", args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
|
|
||||||
bool caps = false;
|
bool caps = false;
|
||||||
std::string url;
|
std::string url;
|
||||||
|
|||||||
Reference in New Issue
Block a user