--- kdebase/workspace/libs/plasma/containment.cpp	2008-12-07 18:58:14.000000000 +0800
+++ kdebase-new/workspace/libs/plasma/containment.cpp	2008-12-07 19:01:26.000000000 +0800
@@ -51,7 +51,7 @@
 #include "desktoptoolbox_p.h"
 #include "paneltoolbox_p.h"
 #include "svg.h"
-
+int Plasma::Containment:: panelNum=0;
 namespace Plasma
 {
 
@@ -228,6 +228,10 @@
         return;
     }
 
+    QString name=group.readEntry("plugin",QString());
+    if(name=="panel"){
+		Plasma::Containment::panelNum++;
+	}
     QRectF geo = group.readEntry("geometry", geometry());
     //override max/min
     //this ensures panels are set to their saved size even when they have max & min set to prevent
@@ -256,13 +260,13 @@
     if (!group.isValid()) {
         group = config();
     }
-
     // locking is saved in Applet::save
     Applet::save(group);
     group.writeEntry("screen", d->screen);
     group.writeEntry("formfactor", (int)d->formFactor);
     group.writeEntry("location", (int)d->location);
     saveContents(group);
+    Plasma::Containment::panelNum++;
 }
 
 void Containment::saveContents(KConfigGroup &group) const
@@ -1035,11 +1039,23 @@
             return;
         }
 
+	if(Plasma::Containment::panelNum<=1){
+		 if (KMessageBox::warningContinueCancel(view(), i18n("This is the last panel! Make sure you know how to add it."),                      i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Cancel ){
+			 return;
+		 }
+	     else {
+			 Applet::destroy();
+			 Plasma::Containment::panelNum--;
+			 return;
+		 }
+     }
+
         //FIXME maybe that %1 should be the containment type not the name
         if (KMessageBox::warningContinueCancel(view(), i18n("Do you really want to remove this %1?", name()),
                     i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Continue ) {
-            //clearApplets();
+            //clearApplets();		
             Applet::destroy();
+			Plasma::Containment::panelNum--;
         }
     } else {
         Applet::destroy();
