Bug 60753 - Wish: Option To Continue When KMail detects a lock
Summary: Wish: Option To Continue When KMail detects a lock
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-04 17:33 UTC by Ender Wiggin
Modified: 2007-09-14 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
error snapshot (181.75 KB, image/png)
2004-03-07 18:29 UTC, Rich Jones
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ender Wiggin 2003-07-04 17:33:26 UTC
Version:           Kmail 1.5.9 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 2.95.3 
OS:          Linux

In my CVS compiled version, sometimes when I shutdown my computer to end my KDE session, KMail leaves behind a lock file. On the next run, I cannot open KMail since it sees the lock file. There must be an option in that dialogue window to let me continue like in KPPP. Or KMail should be smart enough that the lock file is older than the uptime of the computer and should open up automatically.
Comment 1 Thiago Macieira 2003-07-04 18:44:45 UTC
Or, better yet, KMail shouldn't let a lock file behind after a proper shutdown. 
 
Can you describe what happened during shutdown that make KMail let the lock file behind? 
Does it crash? 
Comment 2 Ender Wiggin 2003-07-05 01:45:27 UTC
That's the ideal scenario but I have seen KMail crash and in real life there is no real 
guarantee that such a thing will never happen.  Hence I believe that there should be an 
option to remove/steal the lock and continue.  
Comment 3 Ender Wiggin 2003-07-05 01:47:54 UTC
I have not seen it crash, I usually turn off the machine when I choose to logout of KDE. 
Somehow, someway a lock gets left behind. Also I have seen the cases where KMail 
crashed when logging out but one cannot capture the output since computer is shutting 
down. 
Comment 4 Nick Shaforostoff 2004-01-13 09:55:40 UTC
and remember that we can have this situatuin even if kmail didn't crash, but whole system did

for example, i've installed buggy kde32beta2 and it often leads system to kernel panic, so the next time i have to delete this lock file by myself. i'm tired of this.
Comment 5 Rich Jones 2004-03-07 18:29:14 UTC
Created attachment 5067 [details]
error snapshot
Comment 6 Rich Jones 2004-03-07 18:31:00 UTC
Right. forgot the comment.
I get this error after X crashes (usually after playing with wine..)

If there is no running Kmail, then the lock probably should get removed.
Comment 7 Helge Deller 2004-04-16 23:00:03 UTC
I see this problem too. The basic problem for me is, that I'm using KMail on my laptop at home and in the company. In case KMail crashes at home, the lock will stay with hostname=laptop_home. Then, next time, when I start up KDE at work, my computer gets assigned a new hostname by DHCP, and suddenly KMail thinks the remaining lock belongs to a running KMail on another host.
I agree, that this bug seems only to hurt a few users (like e.g. me), but the user should be able to decide to remove the lock and continue to start up KMail. Let's see, I'll try to do a patch now...
Helge
Comment 8 Helge Deller 2004-04-17 01:55:12 UTC
CVS commit by deller: 

- Add possibility to delete stale lock file when KMail detects a lock (#60753)
- drop QTimer::singleShot() call to newInstance() slot - singleShot() was never used and there is no "newInstance()" slot available anyway.

CCMAIL: 60753-done@bugs.kde.org 


  M +18 -10    kmstartup.cpp   1.24
  M +2 -7      main.cpp   1.192


--- kdepim/kmail/kmstartup.cpp  #1.23:1.24
@@ -12,5 +12,5 @@
 #include <ksimpleconfig.h>
 #include <kstandarddirs.h>
-#include <knotifyclient.h>
+#include <kmessagebox.h>
 #include <dcopclient.h>
 #include <kcrash.h>
@@ -121,13 +121,21 @@ void lockOrDie() {
   if ( !first_instance )
   {
-    QString msg = i18n("Only one instance of KMail can be run at "
-      "any one time. It is already running "
-      "with PID %1 on host %2 according to the lock file located "
-      "at %3.").arg(oldPid).arg(oldHostName).arg(lockLocation);
+    QString msg( i18n("<qt>"
+       "To prevent <b>major damage to your existing mails</b> KMail has "
+       "been locked by another instance of KMail which seems to run "
+       "on host %1 with process id (PID) %2.<br><br>"
+       "In case you are really sure that this instance is not running any "
+       "longer, press <b>Continue</b> to delete the stale lock file and "
+       "restart KMail afterwards again.<br><br>"
+       "If unsure, press <b>Cancel</b>."
+       "</qt>").arg(oldHostName).arg(oldPid) );
 
-    KNotifyClient::userEvent( 0, msg,  KNotifyClient::Messagebox,
-      KNotifyClient::Error );
-    fprintf(stderr, "*** KMail is already running with PID %d on host %s\n",
-            oldPid, oldHostName.local8Bit().data());
+    if (KMessageBox::Continue == KMessageBox::warningContinueCancel(0, 
+         msg, i18n("Warning"), KStdGuiItem::cont(), QString::null, 
+         KMessageBox::Dangerous) ) {
+       // remove stale lock file entry
+       config.writeEntry("pid", -1);
+       config.sync();
+    }
     exit(1);
   }

--- kdepim/kmail/main.cpp  #1.191:1.192
@@ -11,5 +11,4 @@
 #include "kmkernel.h" //control center
 #include "kmail_options.h"
-#include <qtimer.h>
 
 #undef Status // stupid X headers
@@ -52,10 +51,6 @@ void KMailApplication::commitData(QSessi
 int KMailApplication::newInstance()
 {
-  if (dcopClient()->isSuspended())
-  {
-    // Try again later.
-    QTimer::singleShot( 100, this, SLOT(newInstance()) );
+  if (!kmkernel)
     return 0;
-  }
 
   if (!kmkernel->firstInstance() || !kapp->isRestored())


Comment 9 Rich Jones 2004-04-19 13:52:58 UTC
On Friday 16 April 2004 6:55 pm, Helge Deller wrote:
> ------- You are receiving this mail because: -------
> You are a voter for the bug, or are watching someone who is.
>
> http://bugs.kde.org/show_bug.cgi?id=60753
> deller kde org changed:
>
>            What    |Removed                     |Added
> ---------------------------------------------------------------------------
>- Status|NEW                         |RESOLVED
>          Resolution|                            |FIXED
>
>
>
> ------- Additional Comments From deller kde org  2004-04-17 01:55 -------
> CVS commit by deller:
>
...

Thank you very much!!

Rich Jones
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQFAgPxYv9+aDc0/W1ARAqb8AJ4jgVTZ0hh3O7oWHWrltAXfafST1ACeOE+l
b3QJ6ZeIsFZA0/MacZxdA/g=
=+qnE
-----END PGP SIGNATURE-----