INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Definate issue with the plugin stuff  (Read 2491 times)

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
Definate issue with the plugin stuff
« on: April 16, 2002, 02:25:23 pm »

Nikolay/Matt,

Delving deeper into this problem where a plugin's Terminate function is never called I have discovered that even the simplest control causes the problem.

For example in your BusyBox sample I created a new UserControl and set the ControlContainer property to "True" then I added the following code:

Option Explicit

Dim m_oObject               As Object

Public Property Set MyObject(ctl As Object)
   Set m_oObject = ctl
End Property

Private Sub UserControl_Terminate()
   MsgBox "Boo!"
End Sub



And in the Init function of the BusyBox control I added:

   Set UserControl11.MyObject = frmMixer



Now when you run the sample you will not see the msgbox when you exit MJ.

If you comment out the set command in the usercontrol then everything is hunky dorey.


Any thoughts?



Rhino.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42384
  • Shoes gone again!
RE:Definate issue with the plugin stuff
« Reply #1 on: April 16, 2002, 07:23:48 pm »

I believe the form can't be destroyed because there is a living reference to it.  If you do Set UserControl11.MyObject = Nothing, it should be released and everything should clean up.  Can you release your objects on destroy window, or something else similar?

Let us know.

-Matt
Logged
Matt Ashland, JRiver Media Center

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
RE:Definate issue with the plugin stuff
« Reply #2 on: April 16, 2002, 10:58:45 pm »

Matt,

That's my thoughts too.

As I said in my email I tried subclassing but I did not get the messages WM_CLOSE/WM_DESTROY ... but I'll try again.

I really think you should add a terminate call as I will not be the only one hitting this problem and it makes your plugin more logically complete.

This is one issue we've found ... who knows what others may arise as more people develop using your plugin.



Rhino.
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
RE:Definate issue with the plugin stuff
« Reply #3 on: April 17, 2002, 01:02:44 am »

Matt,

Further to the subclassing issue eventually I got it to work and managed to kill my usercontrol.

Unfortunately MJ is still in the background Next Page


For example:


1)  Starting from a clean copy of the BusyBox sample create a new usercontrol and paste in the following into it's code section:

Option Explicit

Dim m_oObject               As Object

Public Property Set MyObject(ctl As Object)
   Set m_oObject = ctl
End Property

Private Sub UserControl_Initialize()
   MsgBox UserControl.Name & "::Initialize"
End Sub

Private Sub UserControl_Terminate()
   Set m_oObject = Nothing
   MsgBox UserControl.Name & "::Terminate"
End Sub



2)  Paste the control onto the busybox control.

3)  In the busybox code remove the existing Init function and add in the following code:

Public Sub Unload()
   MsgBox "BusyBox::Unload Before"
   Set UserControl11.MyObject = Nothing
   MsgBox "BusyBox::Unload After"
End Sub

Public Function Init(ByVal MediaJukebox As Object)
   Set g_MJ = MediaJukebox
   Set g_Interface = Me
   window_Subclass UserControl.hWnd
   Set UserControl11.MyObject = frmMixer
End Function


4)  Create a new module and add in the following code:

Option Explicit

Public g_Interface      As BusyBox.BusyBoxCtrl
Dim hWndNew             As Long
Dim pfnOldProc          As Long

Public Const WM_DESTROY = &H2
Public Const GWL_WNDPROC = (-4)

Public Declare Function SetWindowLongApi Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
  (ByVal dwExStyle As Long, _
  ByVal lpClassName As String, _
  ByVal lpWindowName As String, _
  ByVal dwStyle As Long, _
  ByVal x As Long, _
  ByVal y As Long, _
  ByVal nWidth As Long, _
  ByVal nHeight As Long, _
  ByVal hWndParent As Long, _
  ByVal hMenu As Long, _
  ByVal hInstance As Long, _
  lpParam As Any) As Long


Public Function CallbackWindowProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Select Case wMsg
   Case WM_DESTROY
       MsgBox "WM_DESTROY"
       g_Interface.Unload
       Set g_Interface = Nothing
   End Select
   CallbackWindowProc = CallWindowProc(pfnOldProc, hWnd, wMsg, wParam, lParam)
End Function


Public Sub window_Subclass(ByVal hWnd As Long)
Dim hWndMJ          As Long

   hWndNew = CreateWindowEx(0, "STATIC", "", 0, 0, 0, 0, 0, hWnd, 0, App.hInstance, ByVal 0)
   If hWndNew <> 0 Then
       MsgBox "hWndNew=" & hWndNew
       pfnOldProc = SetWindowLongApi(hWndNew, GWL_WNDPROC, AddressOf CallbackWindowProc)
       If pfnOldProc <> 0 Then
           MsgBox "Subclassed"
       End If
   End If

End Sub




Now when you run the sample, open up busybox and terminate MJ you will see that WM_DESTROY is called and the usercontrol's terminate function is called but still the MJ process is in the background.

Am I doing something wrong?



Rhino.
Logged

Nikolay

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1681
  • Former CTO, JRiver, Inc.
RE:Definate issue with the plugin stuff
« Reply #4 on: April 17, 2002, 12:41:58 pm »

Rhino,

Try build 8.0.251, I have redisigned how plug-ins are freed may be that will help.

Regards,
Nikolay
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
RE:Definate issue with the plugin stuff
« Reply #5 on: April 17, 2002, 12:46:02 pm »

Will do dude.

Any idea when it will be available?

It's 9.45pm here in the UK and I'll be going to bed soon Next Page

So if your not in a hurry to hear if it fixes my problems then I'll try it tomorrow.



Rhino.
Logged

Nikolay

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1681
  • Former CTO, JRiver, Inc.
RE:Definate issue with the plugin stuff
« Reply #6 on: April 17, 2002, 12:57:45 pm »

It should be available in about 1 hour.

Nikolay
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
RE:Definate issue with the plugin stuff
« Reply #7 on: April 17, 2002, 12:59:00 pm »

I'll try and stay up then Next Page



Rhino.
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
RE:Definate issue with the plugin stuff
« Reply #8 on: April 17, 2002, 03:41:19 pm »

8.0.252 didn't work Nikolay.

Using the sample I posted here MJ crashed on exit Next Page

Application popup: Media Jukebox.exe - Application Error : The instruction at "0x734490de" referenced memory at "0x6e696d7a". The memory could not be "read".


Can you please implement a terminate function.

If you are worried about impacting your existing plugins can I make the suggestion that you expose a new object, say MJNotify, with a method called Events where I tell you what I want notified of, e.g.:

Public Function Init(ByVal MediaJukebox As Object)
 Call MediaJukebox.MJNotify.Events( mjEventTerminate Or mjEventTerminate )
End Function


Then you only have to call back *if* you have been asked to do so.

Also this gives you plenty of scope for the future where things like notifications of database changes would be required for other plugins.



Rhino.

Rhino.
Logged
Pages: [1]   Go Up