← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3100: Delete "View as text" files only when their window is closed

 

------------------------------------------------------------
revno: 3100
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-11-01 19:22:20 +0100
message:
  Delete "View as text" files only when their window is closed
modified:
  changelog.txt
  win32/MainWindow.cpp
  win32/TextFrame.cpp
  win32/TextFrame.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2012-10-29 18:19:03 +0000
+++ changelog.txt	2012-11-01 18:22:20 +0000
@@ -1,9 +1,10 @@
 * Fix a race condition on file list download (thanks bigmuscle)
 * [L#668548] Fix a potential infinite loop in BufferedSocket->setDataMode (crise)
 * Add "chunked" transfer encoding as per the HTTP/1.1 spec (crise)
-* [L#1072041] Fix DPI conversion problems (poy
+* [L#1072041] Fix DPI conversion problems (poy)
 * Remove the "Windows UPnP" port mapper in favor of MiniUPnP (poy)
 * Add a UI interface to the plugin API (poy)
+* Delete "View as text" files only when their window is closed (poy)
 
 -- 0.802 2012-10-20 --
 * Perf improvements using lock-free queues, requires P6 CPUs (poy)

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2012-10-29 19:35:54 +0000
+++ win32/MainWindow.cpp	2012-11-01 18:22:20 +0000
@@ -1766,8 +1766,7 @@
 		} else if(qi->isSet(QueueItem::FLAG_TEXT)) {
 			auto file = qi->getTarget();
 			callAsync([this, file] {
-				TextFrame::openWindow(getTabView(), file);
-				File::deleteFile(file);
+				TextFrame::openWindow(getTabView(), file, true, true);
 			});
 		}
 	}

=== modified file 'win32/TextFrame.cpp'
--- win32/TextFrame.cpp	2012-01-13 20:55:20 +0000
+++ win32/TextFrame.cpp	2012-11-01 18:22:20 +0000
@@ -27,6 +27,7 @@
 #include <dwt/widgets/FontDialog.h>
 #include <dwt/widgets/Grid.h>
 
+#include "MainWindow.h"
 #include "WinUtil.h"
 
 using dwt::FontDialog;
@@ -38,8 +39,8 @@
 
 static const size_t MAX_TEXT_LEN = 64*1024;
 
-void TextFrame::openWindow(TabViewPtr parent, const string& fileName, bool activate) {
-	auto window = new TextFrame(parent, fileName);
+void TextFrame::openWindow(TabViewPtr parent, const string& fileName, bool activate, bool temporary) {
+	auto window = new TextFrame(parent, fileName, temporary);
 	if(activate)
 		window->activate();
 }
@@ -57,11 +58,12 @@
 	}
 }
 
-TextFrame::TextFrame(TabViewPtr parent, const string& path) :
+TextFrame::TextFrame(TabViewPtr parent, const string& path, bool temporary) :
 BaseType(parent, Text::toT(Util::getFileName(path)), IDH_TEXT_VIEWER),
 grid(0),
 pad(0),
-path(path)
+path(path),
+temporary(temporary)
 {
 	setIcon(WinUtil::fileImages->getIcon(WinUtil::getFileIcon(path)));
 
@@ -116,6 +118,12 @@
 	grid->resize(r);
 }
 
+void TextFrame::postClosing() {
+	if(temporary && !WinUtil::mainWindow->closing()) {
+		File::deleteFile(path);
+	}
+}
+
 void TextFrame::handleFontChange() {
 	LOGFONT logFont;
 	WinUtil::decodeFont(Text::toT(

=== modified file 'win32/TextFrame.h'
--- win32/TextFrame.h	2012-01-13 20:55:20 +0000
+++ win32/TextFrame.h	2012-11-01 18:22:20 +0000
@@ -28,7 +28,7 @@
 	static const string id;
 	const string& getId() const;
 
-	static void openWindow(TabViewPtr parent, const string& fileName, bool activate = true);
+	static void openWindow(TabViewPtr parent, const string& fileName, bool activate = true, bool temporary = false);
 
 	WindowParams getWindowParams() const;
 	static void parseWindowParams(TabViewPtr parent, const WindowParams& params);
@@ -41,10 +41,11 @@
 private:
 	friend class MDIChildFrame<TextFrame>;
 
-	TextFrame(TabViewPtr parent, const string& path);
+	TextFrame(TabViewPtr parent, const string& path, bool temporary);
 	virtual ~TextFrame() { }
 
 	void layout();
+	void postClosing();
 
 	void handleFontChange();
 
@@ -52,6 +53,7 @@
 	TextBoxPtr pad;
 
 	const string path;
+	const bool temporary;
 };
 
 #endif