[Kst] branches/work/kst/1.6/kst/src/libkstapp

Andrew Walker arwalker at sumusltd.com
Thu Oct 18 21:38:50 CEST 2007


SVN commit 726739 by arwalker:

BUG:150998 avoid a crash in Kst by no longer using a synchronous popup menu

 M  +24 -8     kstviewwidget.cpp  
 M  +4 -0      kstviewwidget.h  


--- branches/work/kst/1.6/kst/src/libkstapp/kstviewwidget.cpp #726738:726739
@@ -41,6 +41,9 @@
 
 
 KstViewWidget::~KstViewWidget() {
+  if (_menu) {
+    delete _menu;
+  }
 }
 
 
@@ -320,23 +323,19 @@
   if (_view->mouseGrabber()) {
     _view->releaseMouse(_view->mouseGrabber());
   }
+
   if (_menu) { // Do not allow recursive menus
     e->ignore();
     return;
   }
+
   _menu = new KPopupMenu(this);
   //kstdDebug() << "Querying for the popup" << endl;
   bool rc = _view->popupMenu(_menu, e->pos());
   if (rc && _menu->count() > 0) {
+    //kstdDebug() << "Showing the popup." << endl;
     _menu->popup(mapToGlobal(e->pos()));
-    //kstdDebug() << "Showing the popup." << endl;
-    _menu->exec();
-    delete _menu;
-    if (_view->viewMode() != KstTopLevelView::DisplayMode) {
-      _view->updateFocus(mapFromGlobal(QCursor::pos()));
-    }
-    // for convenience, let's update the dialogs
-    QTimer::singleShot(0, KstApp::inst(), SLOT(updateVisibleDialogs()));
+    connect(_menu, SIGNAL(aboutToHide()), this, SLOT(menuHiding()));
   } else {
     delete _menu;
   }
@@ -538,5 +537,22 @@
 }
 
 
+void KstViewWidget::menuHiding() {
+  QTimer::singleShot(0, this, SLOT(menuHidden()));
+
+  if (_view->viewMode() != KstTopLevelView::DisplayMode) {
+    _view->updateFocus(mapFromGlobal(QCursor::pos()));
+  }
+
+  // for convenience, let's update the dialogs
+  QTimer::singleShot(0, KstApp::inst(), SLOT(updateVisibleDialogs()));
+}
+
+
+void KstViewWidget::menuHidden() {
+  delete _menu;
+}
+
+
 #include "kstviewwidget.moc"
 
--- branches/work/kst/1.6/kst/src/libkstapp/kstviewwidget.h #726738:726739
@@ -66,6 +66,10 @@
     friend class KstTopLevelView;
     void release() { _view = 0L; }
 
+  protected slots:
+    void menuHiding();
+    void menuHidden();
+
   private:
     KstTopLevelViewPtr _view;
     KstTopLevelView::ViewMode _lastViewMode;


More information about the Kst mailing list