diff --git a/app/src/gambas3/.src/Editor/Form/CControl.class b/app/src/gambas3/.src/Editor/Form/CControl.class index 45cd0288c..405448223 100644 --- a/app/src/gambas3/.src/Editor/Form/CControl.class +++ b/app/src/gambas3/.src/Editor/Form/CControl.class @@ -774,7 +774,10 @@ Public Function Rename(sNewName As String) As Boolean If hForm.Control.Exist(sNewName) Then Return True Endif - hForm.GetEditor(True).RenameControl(Name, sNewName) + ' Don't look in the class when renaming the form! + If Parent Then + hForm.GetEditor(True).RenameControl(Name, sNewName) + Endif If Name Then hForm.Control[Name] = Null diff --git a/app/src/gambas3/.src/Project.module b/app/src/gambas3/.src/Project.module index 42e285ce2..35c9cbede 100644 --- a/app/src/gambas3/.src/Project.module +++ b/app/src/gambas3/.src/Project.module @@ -133,6 +133,7 @@ Private $cSourceDir As Collection Private $hCurrentPopup As Menu +Private $hLock As File Public Sub _init() @@ -298,6 +299,7 @@ Public Function Open(sDir As String, Optional bInAnotherWindow As Boolean) As Bo Dim bSave As Boolean Dim sVer As String Dim sFile As String + Dim hLock As Stream If Not Exist(sDir &/ ".project") Then FGambas.Error(("This project does not exist.") & "\n\n" & sDir) @@ -324,7 +326,9 @@ Public Function Open(sDir As String, Optional bInAnotherWindow As Boolean) As Bo Endif Endif - If Exist(sDir &/ ".lock") Then + Try hLock = Lock sDir &/ ".lock" + + If Not hLock Then If Message.Warning(("This project seems to be already opened.\n\nOpening the same project twice can lead to data loss."), ("Open after all"), ("Do not open")) = 2 Then Return True @@ -333,8 +337,6 @@ Public Function Open(sDir As String, Optional bInAnotherWindow As Boolean) As Bo If CloseProject() Then Return True - Try Kill sDir &/ ".lock" - ReadOnly = Not Access(sDir, gb.Write) If Not ReadOnly Then If Exist(sDir &/ ".startup") And If Not Access(sDir &/ ".startup", gb.Write) Then ReadOnly = True @@ -391,8 +393,8 @@ Public Function Open(sDir As String, Optional bInAnotherWindow As Boolean) As Bo 'FExplorer.ProjectChange Design.Clear Design.ReadBreakpoints - - Try File.Save(sDir &/ ".lock", "") + + $hLock = hLock LastOpenedFiles @@ -409,6 +411,8 @@ Catch _CANCEL: + If hLock Then Try Unlock #hLock + Path = sOldPath Project.Dir = File.Dir(Path) Name = sOldName @@ -521,7 +525,11 @@ Private Function CloseProject() As Boolean Files.Clear ActiveForm = Null - Try Kill Project.Dir &/ ".lock" + If $hLock Then + Unlock #$hLock + Try Kill Project.Dir &/ ".lock" + $hLock = Null + Endif Dec Application.Busy