]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issues #2173 Can't set length on several edges when property panel is undocked,
authornds <nds@opencascade.com>
Thu, 1 Jun 2017 05:25:34 +0000 (08:25 +0300)
committernds <nds@opencascade.com>
Thu, 1 Jun 2017 05:25:34 +0000 (08:25 +0300)
#2169 Segmentation fault when drawing sketch line with undocked property panel

src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp
src/XGUI/XGUI_ErrorDialog.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index c505732941a6984b43cc223c2269e7a34b7f6ec8..8e8f3a22156bff71ccf6ed5a2d7f35edfdc9ff58 100755 (executable)
@@ -118,7 +118,10 @@ void zeroMargins(QLayout* theLayout)
 
 void activateWindow(QWidget* theWidget, const QString& theInfo)
 {
-  theWidget->activateWindow();
+  if (theWidget) {
+    theWidget->activateWindow();
+    theWidget->raise();
+  }
 
 #ifdef DEBUG_ACTIVATE_WINDOW
   qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str());
@@ -127,8 +130,10 @@ void activateWindow(QWidget* theWidget, const QString& theInfo)
 
 void setFocus(QWidget* theWidget, const QString& theInfo)
 {
+  activateWindow(theWidget);
   theWidget->setFocus();
-
+  // rectangle of focus is not visible on tool button widgets
+  theWidget->repaint();
 #ifdef DEBUG_SET_FOCUS
   qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
 #endif
index 2725012c32e1d31c46427612ece7a6951dc79492..af34674d863ced593f0a222b69fa6ae4e211d7f1 100644 (file)
@@ -129,6 +129,8 @@ bool ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals)
     else
       storeValue();
   }
+  ModuleBase_Tools::setFocus(mySpinBox, "ModuleBase_WidgetEditor::editedValue");
+  mySpinBox->selectAll();
 
   if (theSendSignals && !myIsEditing)
     emit enterClicked(this);
index a9808712708913d610b983e7d3500bba44151126..a723c6564c9a12ef798fe83736751ad2368c7415 100644 (file)
@@ -517,7 +517,7 @@ bool PartSet_SketcherReentrantMgr::startInternalEdit(const std::string& thePrevi
             QToolButton* anOkBtn =
               dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_OK);
             if (anOkBtn)
-              anOkBtn->setFocus(Qt::TabFocusReason);
+              ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::activateNextWidget");
           }
         }
       }
index 5c71120f681b20af62eda2345edf8dd764059c43..b07144617027e1c5b78fc4f4ce83c775a6e145ee 100644 (file)
@@ -47,6 +47,7 @@
 #include <QTimer>
 #include <QMenu>
 
+//#define SALOME_PATCH_FOR_CTRL_WHEEL
 
 extern "C" {
 SHAPERGUI_EXPORT CAM_Module* createModule()
@@ -383,6 +384,9 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
     OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
     SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
                                                                  getApp()->selectionMgr());
+#ifdef SALOME_PATCH_FOR_CTRL_WHEEL
+    aViewer->setUseLocalSelection(true);
+#endif
     LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
     QList<SUIT_Selector*> aList;
     aMgr->selectors(aList);
index 70b088848df7583eee28cddb76cadf7d5b885263..46c7d445ad1750a1833e49f344b14dbf89bfecde 100644 (file)
@@ -15,6 +15,8 @@
 #include <QMouseEvent>
 #include <QContextMenuEvent>
 
+//#define SALOME_PATCH_FOR_CTRL_WHEEL
+
 SHAPERGUI_SalomeView::SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer)
 : ModuleBase_IViewWindow(), myCurrentView(0)
 {
@@ -449,6 +451,11 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate)
   if (!mySelector || !mySelector->viewer())
     return;
   SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+#ifdef SALOME_PATCH_FOR_CTRL_WHEEL
+  OCCViewer_Viewer* aViewer = dynamic_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+  if (aViewer)
+    aViewer->setUseLocalSelection(toActivate);
+#endif
   QVector<SUIT_ViewWindow*> aViews = aMgr->getViews();
   if (toActivate) {
     foreach (SUIT_ViewWindow* aView, aViews) {
index 6c278f9d75a71457ab7c48c13dd881f2dfb71056..b7b01fe6964e53b379f4326b827034e9b5e0080a 100644 (file)
@@ -67,7 +67,6 @@ void XGUI_ErrorDialog::addError(std::shared_ptr<Events_InfoMessage> theMsg)
   refresh();
   if (!isVisible()) {
     show();
-    raise();
     ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError");
   }
 }
index 728bd16411c0765e1d92ff4ba5a4dbe5020c6db1..d2930c9c80c84e2434eb04183585093f682057b8 100644 (file)
@@ -66,8 +66,7 @@ public:
             isAccepted = myOperationMgr->onProcessDelete(theObject);
           break;
           default:
-            myOperationMgr->onKeyReleased(theObject, aKeyEvent);
-            isAccepted = true;
+            isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
             break;
         }
       }
@@ -605,10 +604,14 @@ bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
       if (aOperation) {
         ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
         if (aPanel) {
-          // check for case when the operation is started but property panel is not filled
-          XGUI_PropertyPanel* aPP = dynamic_cast<XGUI_PropertyPanel*>(aPanel);
-          aPP->focusNextPrevChild_(theEvent->key() == Qt::Key_Tab);
-          isAccepted = true;
+          QWidget* aFocusedWidget = qApp->focusWidget();
+          bool isPPChildObject = aFocusedWidget && isChildObject(aFocusedWidget, aPanel);
+          if (!isPPChildObject) {
+            // check for case when the operation is started but property panel is not filled
+            XGUI_PropertyPanel* aPP = dynamic_cast<XGUI_PropertyPanel*>(aPanel);
+            aPP->setFocusNextPrevChild(theEvent->key() == Qt::Key_Tab);
+            isAccepted = true;
+          }
         }
       }
     }
index 0659160408f8d1a8e0b38d50319305fdca61b363..5a52c41826819138e44569b4163dce6ba31758d0 100755 (executable)
@@ -281,7 +281,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
       aNewFocusWidget = aCancelBtn;
   }
   if (aNewFocusWidget)
-    aNewFocusWidget->setFocus(Qt::TabFocusReason);
+    ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
 
   activateWidget(NULL);
 }
@@ -342,7 +342,12 @@ void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const b
 #endif
 }
 
-bool XGUI_PropertyPanel::focusNextPrevChild_(bool theIsNext)
+bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
+{
+  return focusNextPrevChild(theIsNext);
+}
+
+bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
 {
   // it wraps the Tabs clicking to follow in the chain:
   // controls, last control, Apply, Cancel, first control, controls
@@ -411,7 +416,6 @@ bool XGUI_PropertyPanel::focusNextPrevChild_(bool theIsNext)
     }
 
     // we want to have property panel as an active window to enter values in double control
-    ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
 
     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
index 0b508df963726d6d3044313b9ac8c5cd84714cae..2a5d2e129979c6886b2df17265a0780724f628da 100644 (file)
@@ -114,6 +114,11 @@ Q_OBJECT
   /// \return button instance or NULL
   QToolButton* findButton(const char* theInternalName) const;
 
+  /// Possibility to process focus by method, for example when Tab or SHIF+Tab is pressed
+  /// but property panel is not active widget
+  /// \param theIsNext true, if Tab(to the next widget) or false(moving to the previous)
+  bool setFocusNextPrevChild(bool theIsNext);
+
 public slots:
   /// \brief Update all widgets in property panel with values from the given feature
   /// \param theFeature a Feature to update values in widgets
@@ -151,13 +156,10 @@ protected:
   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
   /// \param theWidget a widget
   bool setActiveWidget(ModuleBase_ModelWidget* theWidget);
-public:
   /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
   /// Emits a signal about focus change
   /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
-  virtual bool focusNextPrevChild_(bool theIsNext);
-protected:
-  virtual bool focusNextPrevChild(bool theIsNext) { return true; }
+  virtual bool focusNextPrevChild(bool theIsNext);
   /// Activate the next widget in the property panel
   /// \param theWidget a widget. The next widget should be activated
   /// \param isCheckVisibility flag whether the next widget visibility is checked
index 855abacc1a005df52eb3dc1f472729e95ba88dc8..52611057199039ebea4beca3144a52e040cdd88f 100755 (executable)
@@ -1275,7 +1275,6 @@ void XGUI_Workshop::showPropertyPanel()
   // in order to operation manager could process key events of the panel.
   // otherwise they are ignored. It happens only if the same(activateWindow) is
   // not happened by property panel activation(e.g. resume operation of Sketch)
-  ModuleBase_Tools::activateWindow(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()");
   ModuleBase_Tools::setFocus(myPropertyPanel, "XGUI_Workshop::showPropertyPanel()");
 }
 
@@ -1295,7 +1294,6 @@ void XGUI_Workshop::hidePropertyPanel()
   // are processed by this console. For example Undo actions.
   // It is possible that this code is to be moved to SHAPER package
   QMainWindow* aDesktop = desktop();
-  ModuleBase_Tools::activateWindow(aDesktop, "XGUI_Workshop::hidePropertyPanel()");
   ModuleBase_Tools::setFocus(aDesktop, "XGUI_Workshop::showPropertyPanel()");
 }