aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview')
-rw-r--r--linden/indra/newview/llpreviewscript.cpp114
-rw-r--r--linden/indra/newview/llpreviewscript.h11
2 files changed, 78 insertions, 47 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp
index a1c05c7..ca4dcb7 100644
--- a/linden/indra/newview/llpreviewscript.cpp
+++ b/linden/indra/newview/llpreviewscript.cpp
@@ -170,15 +170,22 @@ LLScriptEdCore::LLScriptEdCore(
170 mSampleText(sample), 170 mSampleText(sample),
171 mHelpURL(help_url), 171 mHelpURL(help_url),
172 mEditor( NULL ), 172 mEditor( NULL ),
173 mFunctions(NULL),
174 mErrorList(NULL),
173 mLoadCallback( load_callback ), 175 mLoadCallback( load_callback ),
174 mSaveCallback( save_callback ), 176 mSaveCallback( save_callback ),
175 mSearchReplaceCallback( search_replace_callback ), 177 mSearchReplaceCallback( search_replace_callback ),
176 mUserdata( userdata ), 178 mUserdata( userdata ),
177 mForceClose( FALSE ), 179 mForceClose( FALSE ),
180 mLiveHelpHandle(),
181 mLiveHelpTimer(),
178 mLastHelpToken(NULL), 182 mLastHelpToken(NULL),
179 mLiveHelpHistorySize(0), 183 mLiveHelpHistorySize(0),
180 mEnableSave(FALSE), 184 mEnableSave(FALSE),
181 mEnableXEd(FALSE), 185 mEnableXEd(FALSE),
186 mXstbuf(),
187 mXfname(""),
188 mAutosaveFilename(""),
182 mHasScriptData(FALSE), 189 mHasScriptData(FALSE),
183 // We need to check for a new file every five seconds, or autosave every 60. 190 // We need to check for a new file every five seconds, or autosave every 60.
184 // There's probably a better solution to both of the above. 191 // There's probably a better solution to both of the above.
@@ -284,7 +291,11 @@ BOOL LLScriptEdCore::tick()
284 } 291 }
285 else 292 else
286 { 293 {
287 XedUpd(); 294 // This should really be passed as a parameter -- MC
295 if (!mXfname.empty())
296 {
297 xedUpdateScript();
298 }
288 } 299 }
289 return FALSE; 300 return FALSE;
290} 301}
@@ -509,7 +520,7 @@ void LLScriptEdCore::xedLaunch()
509 fp = NULL; 520 fp = NULL;
510 llinfos << "XEditor: " << mXfname << llendl; 521 llinfos << "XEditor: " << mXfname << llendl;
511 //record the stat 522 //record the stat
512 stat(mXfname.c_str(), &mXstbuf); 523 LLFile::stat(mXfname.c_str(), &mXstbuf);
513 //launch 524 //launch
514#if LL_WINDOWS 525#if LL_WINDOWS
515 //just to get rid of the pesky black window 526 //just to get rid of the pesky black window
@@ -561,43 +572,45 @@ void LLScriptEdCore::xedLaunch()
561#endif 572#endif
562} 573}
563 574
564void LLScriptEdCore::XedUpd() 575void LLScriptEdCore::xedUpdateScript()
565{ 576{
566 struct stat stbuf; 577 llstat stbuf;
567 stat(this->mXfname.c_str() , &stbuf); 578 if (LLFile::stat(this->mXfname.c_str() , &stbuf) == 0) // info found
568 if (this->mXstbuf.st_mtime != stbuf.st_mtime)
569 { 579 {
570 this->mErrorList->addCommentText(std::string("Change Detected... Updating")); 580 if (this->mXstbuf.st_mtime != stbuf.st_mtime)
571 581 {
572 this->mXstbuf = stbuf; 582 this->mErrorList->addCommentText(std::string("Change Detected... Updating"));
573 LLFILE* file = LLFile::fopen(this->mXfname, "rb"); /*Flawfinder: ignore*/ 583
574 if(file) 584 this->mXstbuf = stbuf;
575 { 585 LLFILE* file = LLFile::fopen(this->mXfname, "rb"); /*Flawfinder: ignore*/
576 // read in the whole file 586 if(file)
577 fseek(file, 0L, SEEK_END); 587 {
578 S64 file_length = ftell(file); 588 // read in the whole file
579 fseek(file, 0L, SEEK_SET); 589 fseek(file, 0L, SEEK_END);
580 char* buffer = new char[file_length+1]; 590 S64 file_length = ftell(file);
581 size_t nread = fread(buffer, 1, file_length, file); 591 fseek(file, 0L, SEEK_SET);
582 if (nread < (size_t) file_length) 592 char* buffer = new char[file_length+1];
593 size_t nread = fread(buffer, 1, file_length, file);
594 if (nread < (size_t) file_length)
595 {
596 llwarns << "Short read" << llendl;
597 }
598 buffer[nread] = '\0';
599 fclose(file);
600 std::string ttext = LLStringExplicit(buffer);
601 LLStringUtil::replaceTabsWithSpaces(ttext, 4);
602 mEditor->setText(ttext);
603 LLScriptEdCore::doSave( this, FALSE );
604 //mEditor->makePristine();
605 delete[] buffer;
606 buffer = NULL;
607 }
608 else
583 { 609 {
584 llwarns << "Short read" << llendl; 610 llwarns << "Error opening " << this->mXfname << llendl;
585 } 611 }
586 buffer[nread] = '\0';
587 fclose(file);
588 std::string ttext = LLStringExplicit(buffer);
589 LLStringUtil::replaceTabsWithSpaces(ttext, 4);
590 mEditor->setText(ttext);
591 LLScriptEdCore::doSave( this, FALSE );
592 //mEditor->makePristine();
593 delete[] buffer;
594 buffer = NULL;
595 }
596 else
597 {
598 llwarns << "Error opening " << this->mXfname << llendl;
599 } 612 }
600 } 613 }
601} 614}
602//end dim 615//end dim
603void LLScriptEdCore::autoSave() 616void LLScriptEdCore::autoSave()
@@ -725,6 +738,11 @@ bool LLScriptEdCore::handleSaveChangesDialog(const LLSD& notification, const LLS
725 break; 738 break;
726 739
727 case 1: // "No" 740 case 1: // "No"
741 if( !mAutosaveFilename.empty())
742 {
743 llinfos << "remove autosave: " << mAutosaveFilename << llendl;
744 LLFile::remove(mAutosaveFilename.c_str());
745 }
728 if( !mXfname.empty()) 746 if( !mXfname.empty())
729 { 747 {
730 llinfos << "remove autosave: " << mXfname << llendl; 748 llinfos << "remove autosave: " << mXfname << llendl;
@@ -1343,6 +1361,15 @@ LLPreviewLSL::LLPreviewLSL(const std::string& name, const LLRect& rect,
1343 } 1361 }
1344} 1362}
1345 1363
1364LLPreviewLSL::~LLPreviewLSL()
1365{
1366 if (mScriptEd && !(mScriptEd->mXfname.empty()))
1367 {
1368 llinfos << "remove autosave: " << mScriptEd->mXfname << llendl;
1369 LLFile::remove(mScriptEd->mXfname.c_str());
1370 }
1371}
1372
1346// virtual 1373// virtual
1347void LLPreviewLSL::callbackLSLCompileSucceeded() 1374void LLPreviewLSL::callbackLSLCompileSucceeded()
1348{ 1375{
@@ -1443,10 +1470,10 @@ void LLPreviewLSL::closeIfNeeded()
1443 mPendingUploads--; 1470 mPendingUploads--;
1444 if (mPendingUploads <= 0 && mCloseAfterSave) 1471 if (mPendingUploads <= 0 && mCloseAfterSave)
1445 { 1472 {
1446 if( !mScriptEd->mXfname.empty()) 1473 if (mScriptEd && !mScriptEd->mAutosaveFilename.empty())
1447 { 1474 {
1448 llinfos << "remove autosave: " << mScriptEd->mXfname << llendl; 1475 llinfos << "remove autosave: " << mScriptEd->mAutosaveFilename << llendl;
1449 LLFile::remove(mScriptEd->mXfname.c_str()); 1476 LLFile::remove(mScriptEd->mAutosaveFilename.c_str());
1450 } 1477 }
1451 close(); 1478 close();
1452 } 1479 }
@@ -1901,7 +1928,12 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name,
1901} 1928}
1902 1929
1903LLLiveLSLEditor::~LLLiveLSLEditor() 1930LLLiveLSLEditor::~LLLiveLSLEditor()
1904{ 1931{
1932 if (mScriptEd && (!(mScriptEd->mXfname.empty())))
1933 {
1934 llinfos << "remove autosave: " << mScriptEd->mXfname << llendl;
1935 LLFile::remove(mScriptEd->mXfname.c_str());
1936 }
1905 LLLiveLSLEditor::sInstances.removeData(mItemID ^ mObjectID); 1937 LLLiveLSLEditor::sInstances.removeData(mItemID ^ mObjectID);
1906} 1938}
1907 1939
@@ -2616,10 +2648,10 @@ void LLLiveLSLEditor::closeIfNeeded()
2616 mPendingUploads--; 2648 mPendingUploads--;
2617 if (mPendingUploads <= 0 && mCloseAfterSave) 2649 if (mPendingUploads <= 0 && mCloseAfterSave)
2618 { 2650 {
2619 if( !mScriptEd->mXfname.empty()) 2651 if (mScriptEd && (!mScriptEd->mAutosaveFilename.empty()))
2620 { 2652 {
2621 llinfos << "remove autosave: " << mScriptEd->mXfname << llendl; 2653 llinfos << "remove autosave: " << mScriptEd->mAutosaveFilename << llendl;
2622 LLFile::remove(mScriptEd->mXfname.c_str()); 2654 LLFile::remove(mScriptEd->mAutosaveFilename.c_str());
2623 } 2655 }
2624 close(); 2656 close();
2625 } 2657 }
diff --git a/linden/indra/newview/llpreviewscript.h b/linden/indra/newview/llpreviewscript.h
index 4de886e..cb9cdf4 100644
--- a/linden/indra/newview/llpreviewscript.h
+++ b/linden/indra/newview/llpreviewscript.h
@@ -128,7 +128,7 @@ public:
128 128
129 void autoSave(); 129 void autoSave();
130 //dim external ed 130 //dim external ed
131 void XedUpd(); 131 void xedUpdateScript();
132 void xedLaunch(); 132 void xedLaunch();
133 133
134 virtual BOOL handleKeyHere(KEY key, MASK mask); 134 virtual BOOL handleKeyHere(KEY key, MASK mask);
@@ -150,9 +150,8 @@ private:
150 std::string mSampleText; 150 std::string mSampleText;
151 std::string mAutosaveFilename; 151 std::string mAutosaveFilename;
152 std::string mXfname; 152 std::string mXfname;
153 struct stat mXstbuf; 153 llstat mXstbuf;
154 std::string mHelpURL; 154 std::string mHelpURL;
155 std::string mScriptTitle;
156 LLTextEditor* mEditor; 155 LLTextEditor* mEditor;
157 void (*mLoadCallback)(void* userdata); 156 void (*mLoadCallback)(void* userdata);
158 void (*mSaveCallback)(void* userdata, BOOL close_after_save); 157 void (*mSaveCallback)(void* userdata, BOOL close_after_save);
@@ -160,8 +159,7 @@ private:
160 void* mUserdata; 159 void* mUserdata;
161 LLComboBox *mFunctions; 160 LLComboBox *mFunctions;
162 BOOL mForceClose; 161 BOOL mForceClose;
163 //LLPanel* mGuiPanel; 162 //LLPanel* mCodePanel;
164 LLPanel* mCodePanel;
165 LLScrollListCtrl* mErrorList; 163 LLScrollListCtrl* mErrorList;
166 LLDynamicArray<LLEntryAndEdCore*> mBridges; 164 LLDynamicArray<LLEntryAndEdCore*> mBridges;
167 LLHandle<LLFloater> mLiveHelpHandle; 165 LLHandle<LLFloater> mLiveHelpHandle;
@@ -180,9 +178,10 @@ class LLPreviewLSL : public LLPreview
180public: 178public:
181 LLPreviewLSL(const std::string& name, const LLRect& rect, const std::string& title, 179 LLPreviewLSL(const std::string& name, const LLRect& rect, const std::string& title,
182 const LLUUID& item_uuid ); 180 const LLUUID& item_uuid );
181 ~LLPreviewLSL();
182
183 virtual void callbackLSLCompileSucceeded(); 183 virtual void callbackLSLCompileSucceeded();
184 virtual void callbackLSLCompileFailed(const LLSD& compile_errors); 184 virtual void callbackLSLCompileFailed(const LLSD& compile_errors);
185
186 /*virtual*/ void open(); /*Flawfinder: ignore*/ 185 /*virtual*/ void open(); /*Flawfinder: ignore*/
187 186
188protected: 187protected: