SVN: PLDLiveInstaller/trunk: PLDLiveInstaller.cpp PLDLiveInstaller.h

shadzik shadzik at pld-linux.org
Sat Jan 8 19:32:25 CET 2011


Author: shadzik
Date: Sat Jan  8 19:32:25 2011
New Revision: 12030

Modified:
   PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
   PLDLiveInstaller/trunk/PLDLiveInstaller.h
Log:
- fix crash when using a never before partitioned device (raw device)
- fix crash when partition table and partitions changed while installer was running
- add rereadPartitionTable()
- get size of partition while next is clicked, not while partition is selected


Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.cpp
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.cpp	(original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.cpp	Sat Jan  8 19:32:25 2011
@@ -145,6 +145,19 @@
   }
 }
 
+void PLDLiveInstaller::rereadPartitionTable(QString device)
+{
+  qDebug() << "Re-reading partition table for" << device;
+  QStringList args;
+  args.append("blockdev");
+  args.append("--rereadpt");
+  args.append(device);
+  QProcess * blockdev = new QProcess(this);
+  blockdev->start("chroot", args);
+  blockdev->waitForFinished();
+  blockdev->deleteLater();
+}
+
 void PLDLiveInstaller::isRootPartitionSelected(int pos)
 {
   qDebug() << "rootPart Position: " << pos;
@@ -153,8 +166,9 @@
   {
     QString sizeText;
     qlonglong minSize = 3072;
-    destPartition=diskListWidget->parthash->value(availablePartitions[pos-1]);
-    qlonglong curSize = destPartition.as<Solid::StorageVolume>()->size()/1024/1024; //MB
+    //destPartition=diskListWidget->parthash->value(availablePartitions[pos-1]);
+    //qlonglong curSize = destPartition.as<Solid::StorageVolume>()->size()/1024/1024; //MB
+    qlonglong curSize = curSizeArray[pos-1];
     QString size = QString::number(curSize);
     if(curSize < minSize)
     {
@@ -176,7 +190,8 @@
       sizeText = "Size: " + size + "MB<br />";
     }
     
-    selRoot=destPartition.as<Solid::Block>()->device();
+    //selRoot=destPartition.as<Solid::Block>()->device();
+    selRoot=availablePartitions[pos-1];
     
     partDescr->setText("Partition details:<br />"
 		      "Device: " + selRoot + "<br />"
@@ -1879,6 +1894,7 @@
 	  setAppropriate(selectPartitionsPage, false);
 	else
 	{
+	  rereadPartitionTable(selectedDisk->toolTip());
 	  setAppropriate(selectPartitionsPage, true);
 	qDebug() << "Selected disk:" << selectedDisk->toolTip();
 	if(availablePartitions.count()>0)
@@ -1886,9 +1902,11 @@
 	selectedBlockDev = diskListWidget->devhash->value(selectedDisk->text());
 	if (selectedBlockDev.udi() != NULL) {
 	QString dev = selectedBlockDev.as<Solid::Block>()->device();
+	int i = 0;
 	foreach (Solid::Device partDev, Solid::Device::listFromType(Solid::DeviceInterface::Block, selectedBlockDev.udi()))
 	{
 	  QString part = partDev.as<Solid::Block>()->device();
+	  curSizeArray[i++] = partDev.as<Solid::StorageVolume>()->size()/1024/1024; //MB
 	  availablePartitions.append(part);
 	  qDebug() << dev << "has partition: " << part;
 	}

Modified: PLDLiveInstaller/trunk/PLDLiveInstaller.h
==============================================================================
--- PLDLiveInstaller/trunk/PLDLiveInstaller.h	(original)
+++ PLDLiveInstaller/trunk/PLDLiveInstaller.h	Sat Jan  8 19:32:25 2011
@@ -71,6 +71,8 @@
     void removeJunk(QString filedir, QString argstorm);
     void substr(QString file, QString string1, QString string2);
     void toggleService(QString service, bool action);
+    qlonglong curSizeArray[256];
+    void rereadPartitionTable(QString device);
     
 public:
     PLDLiveInstaller( QWidget * parent = 0 );


More information about the pld-cvs-commit mailing list