It is currently Mon Sep 23, 2019 8:58 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: IMA error with #SCI_SETDOCPOINTER
PostPosted: Sat Jul 06, 2019 2:36 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1098
Location: Germany::Berlin()
Hello

It's not a direct PB bug, but when I use the Scintilla function #SCI_SETDOCPOINTER for the PureBasic ScintillaGadget, PB crashes when I press Ctrl+A and Ctrl+X.
I have developed a new tool for PureBasic to use the SplitView function of Scintilla.
The tool works, but when I press Ctrl+A and Ctrl+X PureBasic crashes with an IMA error.

Example code to enable #SCI_SETDOCPOINTER and reproduce the error:
Code:
EnableExplicit

Procedure GetCurrentScintillaHandle(hwnd, lParam)
  Protected String$
 
  If GetWindowLongPtr_(hwnd, #GWL_STYLE) & #WS_VISIBLE
    String$ = Space(1024)
    GetClassName_(hwnd, @String$, Len(String$))
    If String$ = "Scintilla"
      PokeI(lParam, hwnd)
      ProcedureReturn #False
    EndIf
  EndIf
 
  ProcedureReturn #True
EndProcedure

Procedure GetLastScintillaHandle(hwnd, lParam)
  Protected String$
  Protected ScintillaLength
 
  If GetWindowLongPtr_(hwnd, #GWL_STYLE)
    String$ = Space(1024)
    GetClassName_(hwnd, @String$, Len(String$))
    If String$ = "Scintilla"
      ScintillaLength = SendMessage_(hwnd, #WM_GETTEXTLENGTH, 0, 0)
      If ScintillaLength = 0
        PokeI(lParam, hwnd)
        ProcedureReturn #False
      EndIf
    EndIf
  EndIf
 
  ProcedureReturn #True
EndProcedure

Define PBHandle
Define PBScintillaHandle
Define PBSplitViewScintillaHandle
Define PBScintillaPointer
Define ExampleCode$

ExampleCode$ + "If OpenWindow(0, 0, 0, 500, 400, " + Chr(34) + "Window" + Chr(34) + ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)" + #LFCR$
ExampleCode$ + "  Repeat" + #LFCR$
ExampleCode$ + "    Select WaitWindowEvent()" + #LFCR$
ExampleCode$ + "      Case #PB_Event_CloseWindow" + #LFCR$
ExampleCode$ + "        End" + #LFCR$
ExampleCode$ + "    EndSelect" + #LFCR$
ExampleCode$ + "  ForEver" + #LFCR$
ExampleCode$ + "EndIf" + #LFCR$

SetClipboardText(ExampleCode$)

PBHandle = FindWindow_("WindowClass_2", 0)
If PBHandle
  SendMessage_(PBHandle, #WM_COMMAND, 0, 0)
 
  Delay(250)
 
  keybd_event_(#VK_CONTROL, #Null, #Null, #Null)
  keybd_event_(#VK_V, #Null, #Null, #Null)
  keybd_event_(#VK_CONTROL, #Null, #KEYEVENTF_KEYUP, #Null)
  keybd_event_(#VK_V, #Null, #KEYEVENTF_KEYUP, #Null)
 
  Delay(250)
 
  EnumChildWindows_(PBHandle, @GetCurrentScintillaHandle(), @PBScintillaHandle)
  SendMessage_(PBHandle, #WM_COMMAND, 0, 0)
 
  Delay(250)
 
  EnumChildWindows_(PBHandle, @GetLastScintillaHandle(), @PBSplitViewScintillaHandle)
  If PBScintillaHandle And PBSplitViewScintillaHandle
   
    PBScintillaPointer = SendMessage_(PBScintillaHandle, #SCI_GETDOCPOINTER, 0, 0)
    SendMessage_(PBSplitViewScintillaHandle, #SCI_SETDOCPOINTER, 0, PBScintillaPointer)
   
   
  Else
    Debug "ScintillaGadget not found"
  EndIf
 
Else
  Debug "PB window not found"
EndIf



Steps to reproduce the Invalid Memory Access error:
1. start the code.
2. you now have two new tabs.
2.1 The first new tab is the original tab.
2.2 The second new tab is a pointer tab.
3. choose the original tab.
4. press Ctrl+A and Ctrl+X

Video: https://www.rsbasic.de/temp/PBScintillaBug.mp4

@Fred & @freak:
Is it possible to fix the error so that I can use my tool?

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye