Summary: Fix "last seen" property when quitting kopete

Review Request #6526 - Created Feb. 19, 2011 and submitted

Information
Martin Blumenstingl
kde
trunk
266697
Reviewers
kopete
This patch fixes another problem with kopete's "Last Seen" feature.

If a contact was online when you close kopete no "last seen" time is shown for
the contact (once kopete is started again and the given contact is offline
then).

The reason was quite obvious:
-first the contact list was saved to the XML file.
-then all accounts were told to disconnect
-that updated the last seen property of all contacts
-the contact list was NOT written to the HDD again

I could not find a reason why the two lines should not be moved.
All objects which are required by the AccountManager and the ContactList are still in memory.
But I'd like someone with better Qt event loop knowledge (due to the deleteLater() calls) to review this, as I'm not 100% sure if I haven't overlooked anything.
The "last seen" property now even survives restarts of kopete :)
Raphael Kubo da Costa
Looks OK to an outsider. Where's the event loop code you talked about?
  1. PluginManager::slotPluginReadyForUnload() calls pluginInstance->deleteLater();
    
    It may cause problems if the plugins are deleted before the contact list is written to the Hard-Disk.
    And since the actual deletion of the object is triggered by the event loop at some point it'd be nice if someone could confirm that my code is OK.
  2. Answering the question myself: since PluginManager::shutdown() is called from KopeteWindow::queryExit() it's fine.
    KopeteWindow::queryExit() is called in the "closeEvent" of the window.
    Once the code from the event has been executed Qt returns to the main loop.
    
    In my case this is perfect: the contact list will be saved before the code from the closeEvent has finished executing.
    Thus the Plugins are still in memory and we won't run into any trouble here.
    
    I'll commit in a week if nobody has any objections.
  3. Committed to trunk and backported to 4.6 branch.
    The changelog was updated accordingly.
Loading...