PB Windows IDE not responding for a long time

Everything else that doesn't fall into one of the other PB categories.
User avatar
Demivec
Addict
Addict
Posts: 4282
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PB Windows IDE not responding for a long time

Post by Demivec »

RSrole wrote: Thu Nov 17, 2022 10:48 pm So for the moment, how can I remove the entry from the database? I don't know where it's stored.
It's stored in the IDE's preferences file.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: PB Windows IDE not responding for a long time

Post by Marc56us »

A habit to get into: Test the presence of the file before trying to open it, it is much faster.

Code: Select all

Debug FileSize("\\test\hello\world.txt")   ; -1 file does not exist
If you don't do this, a local network can take up to 20 minutes to respond if there is no local name resolution system (it looks crashed, but it isn't)
Look up NetBIOS over TCP/IP to understand how names propagation works (or not) on a local network in the absence of local DNS.
:wink:
User avatar
mk-soft
Always Here
Always Here
Posts: 6431
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB Windows IDE not responding for a long time

Post by mk-soft »

I have wrote a tool to remove netwerk files from purebasic preferences ;)

Link: Purebasic Preferences Cleaner
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
RSrole
User
User
Posts: 73
Joined: Fri Apr 29, 2022 8:27 pm

Re: PB Windows IDE not responding for a long time

Post by RSrole »

So it's purebasic.pref in C:\Users\{username}\AppData\Roaming\PureBasic
RSrole
User
User
Posts: 73
Joined: Fri Apr 29, 2022 8:27 pm

Re: PB Windows IDE not responding for a long time

Post by RSrole »

So the problem was in Purebasic.prefs. There was an entry in [RecentFiles] that was pointing to a file on a remote computer. The problem, the ip address wasn't valid anymore. So it took awhile for the IDE to timeout and go on to the next entry. The easiest solution (for me) :
Exit Purebasic IDE
run fileexplorer
put %appdata% in the address bar.
Then navigate to "Purebasic"
edit Purebasic.prefs.
Look for [RecentFiles] and find the offending entry.
Delete it and if it's not the last one then fix the RecentProject_xx that follow so they are sequential from the last good one.
Save changes
Run Purebasic again and check
User avatar
mk-soft
Always Here
Always Here
Posts: 6431
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB Windows IDE not responding for a long time

Post by mk-soft »

I known this ...

Small tool

Code: Select all

;-TOP

#ProgramTitle = "Purebasic Preferences Cleaner (No warranty)"
#ProgramCopyright = "©2022 by mk-soft (License MIT)"
#ProgramVersion = "v1.01.3"
#ProgramAbout = #ProgramTitle + #LF$ + #LF$ + #ProgramCopyright + #LF$ + #ProgramVersion

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  #MainMenuAbout
  #MainMenuExit
EndEnumeration

Enumeration Gadgets
  #MainList
  #MainButtonRead
  #MainButtonCleanup
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

; ----

Global IsRead
Global ExplorerPath.s
Global HistorySize
Global ProjectSize
Global OpenedSize
Global OpenedProject.s

Global NewList RecentFiles.s()
Global NewList RecentProject.s()
Global NewList OpenedFiles.s()

; ----

Procedure AddInfo(Text.s)
  AddGadgetItem(#MainList, -1, Text)
EndProcedure

; ----

Procedure.s GetPreferencesPath()
  Protected path.s
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Linux
      path = GetHomeDirectory()
      path + ".purebasic/"
  
    CompilerCase #PB_OS_MacOS
      path = GetHomeDirectory()
      path + ".purebasic/"
      
    CompilerCase #PB_OS_Windows
      path = GetUserDirectory(#PB_Directory_ProgramData)
      path + "purebasic/"
      
  CompilerEndSelect
  
  ProcedureReturn path
    
EndProcedure

; ----

Procedure IsNetPath(File.s)
  Protected r1, path.s
  
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_MacOS
      path = "/Volumes/"
      If Left(File, 9) = path
        r1 = #True
      EndIf
    CompilerCase #PB_OS_Windows
      path = "\\"
      If Left(File, 2) = path
        r1 = #True
      EndIf
    CompilerCase #PB_OS_Linux
      path = "smb-share:"
      If FindString(File, path, 1, #PB_String_NoCase)
        r1 = #True
      EndIf
  CompilerEndSelect
  ProcedureReturn r1
EndProcedure

; ----

Procedure ReadPreferencesFile()
  Protected r1, filename.s, key.s, cnt, temp.s
  
  ExplorerPath = ""
  HistorySize = 0
  OpenedFiles = 0
  ClearList(RecentFiles())
  ClearList(RecentProject())
  ClearList(OpenedFiles())
  
  filename = GetPreferencesPath() + "purebasic.prefs"
  If OpenPreferences(filename)
    AddInfo("Explorer")
    If PreferenceGroup("Explorer")
      ExplorerPath = ReadPreferenceString("path", "")
      If IsNetPath(ExplorerPath)
        AddInfo("! Path: " + ExplorerPath)
      Else
        AddInfo("- Path: " + ExplorerPath)
      EndIf  
    EndIf
    
    AddInfo("RecentFiles")
    If PreferenceGroup("RecentFiles")
      HistorySize = ReadPreferenceInteger("HistorySize", 0)
      AddInfo("- HistorySize: " + HistorySize)
      cnt = 0
      Repeat
        cnt + 1
        key = "RecentFile_" + cnt
        temp = ReadPreferenceString(key, "")
        If temp
          AddElement(RecentFiles())
          RecentFiles() = temp
          If IsNetPath(temp)
            AddInfo("! " + key + ": " + temp)
          Else
            AddInfo("- " + key + ": " + temp)
          EndIf  
        Else
          Break
        EndIf
      ForEver
      cnt = 0
      Repeat
        cnt + 1
        key = "RecentProject_" + cnt
        temp = ReadPreferenceString(key, "")
        If temp
          AddElement(RecentProject())
          RecentProject() = temp
          If IsNetPath(temp)
            AddInfo("! " + key + ": " + temp)
          Else
            AddInfo("- " + key + ": " + temp)
          EndIf  
        Else
          Break
        EndIf
      ForEver
      ProjectSize = ListSize(RecentProject())
    EndIf
    
    AddInfo("OpenedFiles")
    If PreferenceGroup("OpenedFiles")
      OpenedSize = ReadPreferenceInteger("Count", 0)
      AddInfo("- Count: " + OpenedSize)
      cnt = 0
      Repeat
        cnt + 1
        key = "OpenedFile_" + cnt
        temp = ReadPreferenceString(key, "")
        If temp
          AddElement(OpenedFiles())
          OpenedFiles() = temp
          If IsNetPath(temp)
            AddInfo("! " + key + ": " + temp)
          Else
            AddInfo("- " + key + ": " + temp)
          EndIf  
        Else
          Break
        EndIf
      ForEver
      key = "OpenedProject"
      OpenedProject = ReadPreferenceString(key, "")
      If IsNetPath(OpenedProject)
        AddInfo("! " + key + ": " + temp)
      Else
        AddInfo("- " + key + ": " + temp)
      EndIf  
    EndIf
    ClosePreferences()
    r1 = #True
  Else
    AddInfo("Can't open preferences file!")
    r1 = #False
  EndIf
  
  ProcedureReturn r1
  
EndProcedure

; ----

Procedure CleanUpPreferencesFile()
  Protected r1, filename.s, key.s, cnt, temp.s, path.s, len, do
  
  AddInfo("Start CleanUp ...")
  
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_MacOS
      path = "/Volumes/"
      len = Len(path)
      
    CompilerCase #PB_OS_Windows
      path = #PS$ + #PS$
      len = Len(path)
      
    CompilerCase #PB_OS_Linux
      path = "smb-share:"
      len = 0
      
  CompilerEndSelect
  
  filename = GetPreferencesPath() + "purebasic.prefs"
  If OpenPreferences(filename)
    AddInfo("Explorer")
    If PreferenceGroup("Explorer")
      If IsNetPath(ExplorerPath)
        ExplorerPath = GetHomeDirectory()
        WritePreferenceString("path", ExplorerPath)
        AddInfo("- Update Path: " + ExplorerPath)
      Else
        AddInfo("- No change")
      EndIf
    EndIf
    
    AddInfo("RecentFiles")
    If PreferenceGroup("RecentFiles")
      do = #False
      ForEach RecentFiles()
        If IsNetPath(RecentFiles())
          DeleteElement(RecentFiles())
          do = #True
        EndIf
      Next
      If do
        For cnt = 1 To HistorySize
          key = "RecentFile_" + cnt
          RemovePreferenceKey(key)
        Next
        HistorySize = ListSize(RecentFiles())
        WritePreferenceInteger("HistorySize", HistorySize)
        AddInfo("- Update HistorySize: " + HistorySize)
        
        cnt = 0
        ForEach RecentFiles()
          cnt + 1
          key = "RecentFile_" + cnt
          temp = RecentFiles()
          WritePreferenceString(key, temp)
          AddInfo("- Update " + key + ": " + temp)
        Next
      Else
        AddInfo("- No change recent files")
      EndIf
      
      do = #False
      ForEach RecentProject()
        If IsNetPath(RecentProject())
          DeleteElement(RecentProject())
          do = #True
        EndIf
      Next
      If do
        For cnt = 1 To ProjectSize
          key = "RecentProject_" + cnt
          RemovePreferenceKey(key)
        Next
        cnt = 0
        ForEach RecentProject()
          cnt + 1
          key = "RecentProject_" + cnt
          temp = RecentProject()
          WritePreferenceString(key, temp)
          AddInfo("- Update " + key + ": " + temp)
        Next
      Else
        AddInfo("- No change recent projects")
      EndIf
        
    EndIf
    
    AddInfo("OpenedFiles")
    If PreferenceGroup("OpenedFiles")
      do = #False
      ForEach OpenedFiles()
        If IsNetPath(OpenedFiles())
          DeleteElement(OpenedFiles())
          do = #True
        EndIf
      Next
      If do
        For cnt = 1 To OpenedSize
          key = "OpenedFile_" + cnt
          RemovePreferenceKey(key)
        Next
        OpenedSize = ListSize(OpenedFiles())
        WritePreferenceInteger("Count", OpenedSize)
        AddInfo("- Update Count: " + OpenedSize)
        
        cnt = 0
        ForEach OpenedFiles()
          cnt + 1
          key = "OpenedFile_" + cnt
          temp = OpenedFiles()
          WritePreferenceString(key, temp)
          AddInfo("- Update " + key + ": " + temp)
        Next
      Else
        AddInfo("- No change opened files")
      EndIf
      If IsNetPath(OpenedProject)
        key = "OpenedProject"
        temp = "[Nothing]"
        WritePreferenceString(key, "")
        AddInfo("- Clear OpenedProject " + key + ": " + temp)
      Else
        AddInfo("- No change opened project")
      EndIf
    EndIf
    ClosePreferences()
    r1 = #True
    AddInfo("Finished CleanUp.")
  Else
    AddInfo("Can't open preferences file!")
    r1 = #False
  EndIf
  
  ProcedureReturn r1
  
EndProcedure

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
  ; Resize gadgets
  ResizeGadget(#MainList, 5, 5, dx -10, dy - 45)
  ResizeGadget(#MainButtonRead, 10, dy - 35, 120, 30)
  ResizeGadget(#MainButtonCleanup, dx - 130, dy - 35, 120, 30)
  EndProcedure

Procedure Main()
  Protected dx, dy
  Protected r1
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("&File")
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
      MenuItem(#PB_Menu_About, "")
    CompilerElse
      MenuItem(#MainMenuAbout, "About")
      MenuBar()
    CompilerEndIf
    
    MenuItem(#MainMenuExit, "E&xit")
    
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
    ListViewGadget(#MainList, 5, 5, dx - 10, dy - 45)
    ButtonGadget(#MainButtonRead, 10, dy - 35, 120, 30, "Read")
    ButtonGadget(#MainButtonCleanup, dx - 130, dy - 35, 120, 30, "CleanUp")
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    
    ; Event Loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case #Main
              Break
              
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
            
          Case #MainMenuAbout
            MessageRequester("About", #ProgramAbout, #PB_MessageRequester_Info)
              
          Case #MainMenuExit
            PostEvent(#PB_Event_CloseWindow, #Main, #Null)
            
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainButtonRead
              ClearGadgetItems(#MainList)
              IsRead = ReadPreferencesFile()
              
            Case #MainButtonCleanup
              If IsRead
                r1 = MessageRequester("Question", "Start Preferences CleanUp?", #PB_MessageRequester_Warning | #PB_MessageRequester_YesNo)
                If r1 = #PB_MessageRequester_Yes
                  ClearGadgetItems(#MainList)
                  CleanUpPreferencesFile()
                EndIf
              EndIf
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply