#! /bin/sh /usr/share/dpatch/dpatch-run
## 20_reset-frontend-data.dpatch by <zsu@novell.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: 

@DPATCH@
diff --git a/src/qsciminputcontext.cpp b/src/qsciminputcontext.cpp
index 0123952..d436ba8 100644
--- a/src/qsciminputcontext.cpp
+++ b/src/qsciminputcontext.cpp
@@ -658,6 +658,8 @@ QScimInputContext::QScimInputContext()
 
     if (global.shared_input_method)
         m_is_on = global.config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), m_is_on);
+    // Associate this context with the instance.
+    m_instance->set_frontend_data (static_cast<void*> (this));
 
     global.panel_client->prepare (m_id);
     global.panel_client->register_input_context (m_id, m_instance->get_factory_uuid ());
@@ -900,6 +902,7 @@ QScimInputContext::finalize ()
         // Only do full finalize, if the Panel doesn't exit.
         if (!global.panel_exited) {
             global.panel_client->prepare (m_id);
+            m_instance->set_frontend_data (static_cast<void*>(this));
  
             if (global.focused_ic == this)
                 m_instance->focus_out ();
@@ -911,6 +914,7 @@ QScimInputContext::finalize ()
             QScimInputContext *old_focused = global.focused_ic;
             global.focused_ic = this;
             // XXX: Free the smart pointer, not reset the instance.
+            m_instance->set_frontend_data (0);
             m_instance.reset ();
             global.focused_ic = old_focused;
  
@@ -922,6 +926,7 @@ QScimInputContext::finalize ()
             global.panel_client->remove_input_context (m_id);
             global.panel_client->send ();
         } else {
+            m_instance->set_frontend_data (0);
             m_instance.reset ();
         }
     }
