Permalink
Browse files

Add the ability for the mount tray to "force" an unmount (given a war…

…ning ahead of time)
  • Loading branch information...
1 parent 408039b commit 22f21be64b1074c46564d2f13c6526e7553b0fdb Ken Moore committed Aug 26, 2013
Showing with 11 additions and 2 deletions.
  1. +10 −1 src-qt4/pc-mounttray/menuItem.cpp
  2. +1 −1 src-qt4/pc-mounttray/menuItem.h
@@ -253,7 +253,7 @@ void MenuItem::mountItem(){
}
-void MenuItem::unmountItem(){
+void MenuItem::unmountItem(bool force){
//Unmount the device
//Check to see if the current mountpoint exists or if it is somewhere else
@@ -265,6 +265,7 @@ void MenuItem::unmountItem(){
}
//Make sure there are no spaces in the mounpoint path
QString cmd1 = "umount \"" + mountpoint +"\"";
+ if(force){ cmd1.replace("umount ","umount -f "); }
QString cmd2 = "rmdir \"" + mountpoint +"\"";
qDebug() << "Unmounting device from" << mountpoint;
//Run the commands
@@ -287,6 +288,14 @@ void MenuItem::unmountItem(){
result = tr("It is now safe to remove the device");
}
}else{
+ if(!force){
+ if(QMessageBox::Yes == QMessageBox::question(0,tr("Device Busy"),
+ tr("The device appears to be busy. Would you like to unmount it anyway?")+"\n\n"+tr("NOTE: This is generally not recommended unless you are sure that you don't have any applications using the device."),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ unmountItem(true); //force the unmount recursively
+ return;
+ }
+ }
qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint;
qDebug() << " - Error message:" << output;
title = QString( tr("Error: %1 could not be unmounted") ).arg(devLabel->text());
@@ -59,7 +59,7 @@ class MenuItem : public QWidgetAction
QCheckBox* checkAutomount;
//void mountItem();
- void unmountItem();
+ void unmountItem(bool force = false);
void updateSizes();
QString getSizeDisplay(int);
bool checkSavedAutoMount();

0 comments on commit 22f21be

Please sign in to comment.