enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
+/*!
+ \class BusyLocker
+ \brief Simple 'busy state' flag locker.
+ \internal
+*/
+
+class BusyLocker
+{
+public:
+ //! Constructor. Sets passed boolean flag to \c true.
+ BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
+ //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
+ ~BusyLocker() { myBusy = false; }
+private:
+ bool& myBusy; //! External 'busy state' boolean flag
+};
+
//=================================================================================
// class : SMESHGUI_TranslationDlg()
// purpose :
//=================================================================================
void SMESHGUI_TranslationDlg::ClickOnApply()
{
- if (mySMESHGUI->isActiveStudyLocked())
+ if (mySMESHGUI->isActiveStudyLocked() || myBusy )
return;
+ BusyLocker lock( myBusy );
if (myNbOkElements) {
QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
QLineEdit* send = (QLineEdit*)sender();
if (myBusy) return;
- myBusy = true;
+ BusyLocker lock( myBusy );
if (send == LineEditElements)
myNbOkElements = 0;
if (myNbOkElements) {
buttonOk->setEnabled(true);
buttonApply->setEnabled(true);
- }
- myBusy = false;
+ }
}
//=================================================================================
//=================================================================================
void SMESHGUI_TranslationDlg::SelectionIntoArgument()
{
- if (myBusy) return;
+ if (myBusy)
+ return;
+ BusyLocker lock( myBusy );
// clear
myActor = 0;
QString aString = "";
- myBusy = true;
if (myEditCurrentArgument == (QWidget*)LineEditElements) {
LineEditElements->setText(aString);
myNbOkElements = 0;
buttonOk->setEnabled(false);
buttonApply->setEnabled(false);
}
- myBusy = false;
- if (!GroupButtons->isEnabled()) // inactive
+ if (!GroupButtons->isEnabled()) // inactive
return;
// get selected mesh
}
}
- myBusy = true;
if (myEditCurrentArgument == (QWidget*)LineEditElements) {
LineEditElements->setText(aString);
+ LineEditElements->repaint();
setNewMeshName();
}
- myBusy = false;
// OK
if (myNbOkElements) {
//=================================================================================
void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
{
+ if (myBusy) return;
+ BusyLocker lock( myBusy );
+
QPushButton* send = (QPushButton*)sender();
disconnect(mySelectionMgr, 0, this, 0);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode( CellSelection );
- SelectionIntoArgument();
+ // SelectionIntoArgument();
}
//=================================================================================