aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-09-15 07:51:17 -0700
committerMcCabe Maxsted2010-09-15 08:16:51 -0700
commit06c0a0e540ec18e1adc458d14f476f65f51ac28f (patch)
treeb60f93a856cd89e26cbd7e9cf81d654befc4e5fb /linden/indra
parentAdded LSL and LSL2 to the en_sl dictionary (diff)
downloadmeta-impy-06c0a0e540ec18e1adc458d14f476f65f51ac28f.zip
meta-impy-06c0a0e540ec18e1adc458d14f476f65f51ac28f.tar.gz
meta-impy-06c0a0e540ec18e1adc458d14f476f65f51ac28f.tar.bz2
meta-impy-06c0a0e540ec18e1adc458d14f476f65f51ac28f.tar.xz
Fixed crash when pressing the download dictionary button right after the window opened
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/newview/lggdicdownload.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/linden/indra/newview/lggdicdownload.cpp b/linden/indra/newview/lggdicdownload.cpp
index 5b8b13a..8cd9795 100644
--- a/linden/indra/newview/lggdicdownload.cpp
+++ b/linden/indra/newview/lggdicdownload.cpp
@@ -49,10 +49,11 @@
49#include "llbufferstream.h" 49#include "llbufferstream.h"
50 50
51class lggDicDownloadFloater; 51class lggDicDownloadFloater;
52
52class EmeraldDicDownloader : public LLHTTPClient::Responder 53class EmeraldDicDownloader : public LLHTTPClient::Responder
53{ 54{
54public: 55public:
55 EmeraldDicDownloader(lggDicDownloadFloater * spanel,std::string sname); 56 EmeraldDicDownloader(lggDicDownloadFloater* spanel, std::string sname);
56 ~EmeraldDicDownloader() { } 57 ~EmeraldDicDownloader() { }
57 void completedRaw( 58 void completedRaw(
58 U32 status, 59 U32 status,
@@ -77,9 +78,11 @@ public:
77 std::vector<std::string> lNames; 78 std::vector<std::string> lNames;
78 LLPrefsAdvanced * empanel; 79 LLPrefsAdvanced * empanel;
79}; 80};
81
80lggDicDownloadFloater::~lggDicDownloadFloater() 82lggDicDownloadFloater::~lggDicDownloadFloater()
81{ 83{
82} 84}
85
83lggDicDownloadFloater::lggDicDownloadFloater(const LLSD& seed) 86lggDicDownloadFloater::lggDicDownloadFloater(const LLSD& seed)
84{ 87{
85 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_dictionaries.xml"); 88 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_dictionaries.xml");
@@ -89,96 +92,96 @@ lggDicDownloadFloater::lggDicDownloadFloater(const LLSD& seed)
89 { 92 {
90 center(); 93 center();
91 } 94 }
92
93} 95}
94 96
95BOOL lggDicDownloadFloater::postBuild(void) 97BOOL lggDicDownloadFloater::postBuild(void)
96{ 98{
97 childSetAction("Emerald_dic_download",onClickDownload,this); 99 childSetAction("Emerald_dic_download", onClickDownload, this);
98 return true; 100 return true;
99} 101}
100void lggDicDownloadFloater::setData(std::vector<std::string> shortNames, std::vector<std::string> longNames, void * data) 102
103void lggDicDownloadFloater::setData(std::vector<std::string> shortNames, std::vector<std::string> longNames, void* data)
101{ 104{
102 sNames=shortNames; 105 sNames = shortNames;
103 lNames=longNames; 106 lNames = longNames;
104 empanel = (LLPrefsAdvanced*)data; 107 empanel = (LLPrefsAdvanced*)data;
105 108
106 LLComboBox* comboBox = getChild<LLComboBox>("Emerald_combo_dics"); 109 LLComboBox* comboBox = getChild<LLComboBox>("Emerald_combo_dics");
107 if(comboBox != NULL) 110 if (comboBox != NULL)
108 { 111 {
109 comboBox->removeall(); 112 comboBox->removeall();
110 comboBox->add(""); 113 for (int i = 0; i < (int)lNames.size(); i++)
111 for(int i = 0; i < (int)lNames.size(); i++)
112 { 114 {
113 comboBox->add(lNames[i]); 115 comboBox->add(lNames[i], ADD_BOTTOM);
114 } 116 }
115 comboBox->setCurrentByIndex(0); 117 comboBox->setCurrentByIndex(0);
118 comboBox->add("", ADD_BOTTOM);
116 } 119 }
117} 120}
121
118void lggDicDownloadFloater::onClickDownload(void* data) 122void lggDicDownloadFloater::onClickDownload(void* data)
119{ 123{
120 lggDicDownloadFloater* self = (lggDicDownloadFloater*)data; 124 lggDicDownloadFloater* self = (lggDicDownloadFloater*)data;
121 if(self) 125 if (self)
122 { 126 {
123 //std::string selection = self->childGetValue("Emerald_combo_dics").asString(); 127 //std::string selection = self->childGetValue("Emerald_combo_dics").asString();
124 LLComboBox* comboBox = self->getChild<LLComboBox>("Emerald_combo_dics"); 128 LLComboBox* comboBox = self->getChild<LLComboBox>("Emerald_combo_dics");
125 if(comboBox != NULL) 129 if (comboBox != NULL)
126 { 130 {
127 int index = comboBox->getCurrentIndex(); 131 if (!comboBox->getSelectedItemLabel().empty())
128 if(index!=0)
129 { 132 {
130 index--; 133 std::string newDict(self->sNames[comboBox->getCurrentIndex()]);
131 std::string newDict(self->sNames[index]);
132 LLHTTPClient::get(gSavedSettings.getString("DicDownloadBaseURL")+newDict+".aff", new EmeraldDicDownloader(self,newDict+".aff")); 134 LLHTTPClient::get(gSavedSettings.getString("DicDownloadBaseURL")+newDict+".aff", new EmeraldDicDownloader(self,newDict+".aff"));
133 LLHTTPClient::get(gSavedSettings.getString("DicDownloadBaseURL")+newDict+".dic", new EmeraldDicDownloader(NULL,newDict+".dic")); 135 LLHTTPClient::get(gSavedSettings.getString("DicDownloadBaseURL")+newDict+".dic", new EmeraldDicDownloader(NULL,newDict+".dic"));
134 136
135 LLButton* butt = self->getChild<LLButton>("Emerald_dic_download"); 137 LLButton* button = self->getChild<LLButton>("Emerald_dic_download");
136 if(butt) 138 if (button)
137 { 139 {
138 butt->setLabel(LLStringExplicit("Downloading... Please Wait")); 140 // TODO: move this to xml
139 butt->setEnabled(FALSE); 141 button->setLabel(LLStringExplicit("Downloading... Please Wait"));
142 button->setEnabled(FALSE);
140 } 143 }
141
142 } 144 }
143 } 145 }
144 } 146 }
145
146
147} 147}
148 148
149void LggDicDownload::show(BOOL showin, std::vector<std::string> shortNames, std::vector<std::string> longNames, void * data) 149void LggDicDownload::show(BOOL showin, std::vector<std::string> shortNames, std::vector<std::string> longNames, void * data)
150{ 150{
151 if(showin) 151 if (showin)
152 { 152 {
153 lggDicDownloadFloater* dic_floater = lggDicDownloadFloater::showInstance(); 153 lggDicDownloadFloater* dic_floater = lggDicDownloadFloater::showInstance();
154 dic_floater->setData(shortNames,longNames,data); 154 dic_floater->setData(shortNames,longNames,data);
155 } 155 }
156} 156}
157EmeraldDicDownloader::EmeraldDicDownloader(lggDicDownloadFloater* spanel, std::string sname): 157
158panel(spanel),name(sname){} 158EmeraldDicDownloader::EmeraldDicDownloader(lggDicDownloadFloater* spanel, std::string sname)
159 :
160 panel(spanel),
161 name(sname)
162{
163}
159 164
160 165
161void EmeraldDicDownloader::completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) 166void EmeraldDicDownloader::completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer)
162{ 167{
163 if(status < 200 || status >= 300) 168 if (status < 200 || status >= 300)
164 { 169 {
165 return; 170 return;
166 } 171 }
167 LLBufferStream istr(channels, buffer.get()); 172 LLBufferStream istr(channels, buffer.get());
168 std::string dicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", 173 std::string dicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", name.c_str()));
169 name.c_str())); 174
170
171
172 llofstream ostr(dicpath, std::ios::binary); 175 llofstream ostr(dicpath, std::ios::binary);
173 176
174 while(istr.good() && ostr.good()) 177 while (istr.good() && ostr.good())
178 {
175 ostr << istr.rdbuf(); 179 ostr << istr.rdbuf();
180 }
176 ostr.close(); 181 ostr.close();
177 if(panel) 182 if (panel)
178 { 183 {
179 panel->empanel->refresh(); 184 panel->empanel->refresh();
180 panel->close(); 185 panel->close();
181 } 186 }
182
183
184} 187}