[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdemultimedia/noatun/library
From:       Stefan Gehn <mETz81 () web ! de>
Date:       2007-01-21 19:44:36
Message-ID: 1169408676.850750.19353.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 625982 by metz:

- fix saving playlists by deleting the QTextStream that is used for writing, ensures \
                that contents end up in tempfile
- purge WA_DeleteOnClose attribute from NMainWindow for now, eventually plugins can \
decide that later on


 M  +5 -2      nmainwindow.cpp  
 M  +17 -6     playlistsaver.cpp  


--- trunk/KDE/kdemultimedia/noatun/library/nmainwindow.cpp #625981:625982
@@ -28,6 +28,9 @@
 NMainWindow::NMainWindow(Plugin *plug, bool isSkinned, bool wantNoatunXML, QWidget* \
parent, Qt::WindowFlags f)  : KMainWindow(parent, f)
 {
+	//TODO: Should this decision be up to the plugins using NMainWindow?
+	setAttribute(Qt::WA_DeleteOnClose, false);
+
 	//kDebug(66666) << k_funcinfo << "plugin instancename = " << \
plug->instance()->instanceName() << endl;  d = new Private;
 //	kapp->ref();
@@ -37,7 +40,7 @@
 	d->plugin = plug;
 	setInstance(plug->instance());
 	updateSkin();
-	
+
 	StdAction::playpause(plug->global(), actionCollection());
 }
 
@@ -66,7 +69,7 @@
 		{
 			/*kDebug(66666) << k_funcinfo <<
 				"MERGING IN " << locate("data", "noatun/noatun.rc") << endl;*/
-			
+
 			KXMLGUIClient::setXMLFile("noatun/noatun.rc", true);
 			d->bMergedNoatunXML = true;
 		}
--- trunk/KDE/kdemultimedia/noatun/library/playlistsaver.cpp #625981:625982
@@ -35,26 +35,36 @@
 
 bool PlaylistSaver::save(const KUrl &url, const PlaylistType opt)
 {
-//	kDebug(66666) << k_funcinfo << "opt=" << opt << endl;
+	//kDebug(66666) << k_funcinfo << "url:" << url << "; opt:" << opt << endl;
 	if(url.isEmpty() || !url.isValid() || (opt == PLS) || (opt == ASX) )
 		return false;
 
 	bool ret = false;
 	KTemporaryFile tmpFile;
+	tmpFile.setSuffix(".noatunplaylist.xml");
 
 	if (tmpFile.open())
 	{
-		QTextStream textStream(&tmpFile);
+		QTextStream *stream = new QTextStream(&tmpFile);
 		if (opt == M3U || opt == EXTM3U)
-			ret = saveM3U(textStream, opt);
+			ret = saveM3U(*stream, opt);
 		else  // It's a XMLPlaylist
-			ret = saveXML(textStream);
+			ret = saveXML(*stream);
+		delete stream;
 
 		if (ret) // saving worked
+		{
 			ret = KIO::NetAccess::upload(tmpFile.fileName(), url, 0L);
+		}
 		else
-			kWarning(66666) << "Couldn't save playlist to temporary file '" << \
tmpFile.fileName() << "'!" << endl; +		{
+			kWarning(66666) << "Couldn't save playlist to temporary file" << \
tmpFile.fileName() << endl; +		}
 	}
+	else
+	{
+		kWarning(66666) << "Couldn't open temporary file " << tmpFile.fileName() << endl;
+	}
 	return ret;
 }
 
@@ -113,6 +123,7 @@
 	return res;
 }
 
+
 bool PlaylistSaver::metalist(const QString &file, const KUrl &originalUrl)
 {
 	if(loadXML(file, XMLPlaylist))
@@ -126,6 +137,7 @@
 	return false;
 }
 
+
 bool PlaylistSaver::saveXML(QTextStream &stream)
 {
 	QDomDocument doc("playlist");
@@ -158,7 +170,6 @@
 
 	stream.setCodec(QTextCodec::codecForName("UTF-8"));
 	stream << doc.toString();
-
 	return true;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic