Win32ole issues
-
I have a commercial Ruby plugin toolset that reads/writes Excel XLS/XLSX files using Win32ole [PC only].
It makes 3d geometry from them or writes 3d geometry to them in client specific formats.
So far so good...
It works fine on their 32bit Win7 system [and my 32bit Vista].
When the client just tried it on a new 64bit Win7 PC it Bugsplatted [not immediately, but a few seconds after the tool has added some geometry or exported data to a new XLS file] !
I've just tested it on a 64bit PC and I find that [unlike on a 32bit PC ] it is failing to Quit Excel as it should after the tool ends [with Excel read OR write]... and that seemed to cause a memory-leak that leads to the Bugsplat shortly thereafter.
It's not connected to accessing the SKP database per se, because simply reading/writing a value from/to the XLS and then trying to Quit Excel will Bugsplat.
I have managed to stop the near-instant Bugsplat by using some GC Garbage-Collection etc in revised code - it now works problem-free on 32bit BUT on a 64bit you can run the tool, save etc but when exiting Sketchup there's a Bugsplat after it's closed its window - clearly something isn't quite right yet...
Incidentally on 32bit the running Excel process is called 'EXCEL.EXE', but on 64bit 'EXCEL.EXE*32' so I guess this might prevent a neat Quit ?
Does anyone have any ideas how to resolve this completely ?Below is the code that works fine on 32bit [you need to have Win32ole.so in the Plugins folder]
require('win32ole.so') ### We could start in another folder ### but for simplicity let's do this... xlsp=UI.openpanel("Choose the XLS File", Dir.pwd, "*") ### code to check file's validity omitted here for simplicity. excel=WIN32OLE;;new('Excel.Application') xls=excel.Workbooks.Open(xlsp) sheet=xls.Worksheets('SKP') ### NOTE the XLS file MUST contain a worksheet named 'SKP' so ### make sure your test XLS has one ! ### The code to check its validity is omitted for simplicity. puts a1=sheet.Range('A1').Value.to_s ### This is a VERY simple example. ### It returns the value of cell 'A1' - so ensure it has a value. ### This writes a value into cell 'B1' sheet.Range('B1').Value=a1+'_TIG' xls.Save(xlsp) ### ### We now do all of the data reading or writing... ### ### When we're done we close and quit. xls.Close() excel.Quit()
This all works just fine for 32bit.
BUT for 64bit it needs this extra code added to the end, to [almost] stop the BUGsplat issuesWIN32OLE.ole_free(excel) excel.ole_free ### Is this an alternative ? sheet=nil xls=nil excel=nil GC.start
This then Quits Excel properly and then lets you carry on working in the SKP, but a Bugsplat IS being saved up for when you close Sketchup
What else do I need to add to this to stop Sketchup exiting 'messily' ??
I'm even unsure about what might now be causing these issues...
-
disable BugSplat and try to find the reason of crash (usually some COM things not properly initialized/finalized )
-
@unknownuser said:
disable BugSplat and try to find the reason of crash (usually some COM things not properly initialized/finalized )
How do I disable Bugsplat ?The entire block of code is all as I posted [no more needed!], for a 64bit initial almost instant Bugsplat as Excel tries to Quit, or when adjusted with the additional ole_free..=nil..GC.start etc it Quits OK, but eventually Bugsplats when Sketchup is closed... so where'd a COM issue come from ?
I'm afraid that Win32ole is a bit beyond my normal level of programming - it was relatively easy to get the 32bit version working as needed as a simple extension of Ruby - bloody 64bit Windows !To complicate matters I don't have regular access access to a 64bit Win7 PC to test ideas on either
-
Hi Tig.
I tried this on my machine (Vista64), and it does not bug splat. I had to add require('win32ole') to get it to work.
One thing I noticed is that I get a popup from Excel asking if I want to save the changes I made. If I let that sit unanswered for a while, I get a "server busy" popup from Sketchup, saying "this action cannot be completed because the other program is busy".... Maybe you want to try xls.saveas("whatever.xlsx") -
daiku
Thank's for the info.
Sorry... but the code is only snippets; I missed out the line
xls.SaveAs(xlsp)
that's needed if you reset a value...
I've edited the earlier code to include that now !
If you retest it with the full code is it OK ?
Does it break with the 32bit version of the code, that ends atexcel.Quit()
?
Your lack of Bugsplats is puzzling...
Perhaps my client has something else running that doesn't like these interactions ???
Are you on v8M2 64bit Win7 ? -
@unknownuser said:
How do I disable Bugsplat ?
iirc you need a debug=1 registry and then http://www.ishouldbeallowedtothink.com/suwiki/index.php?title=Debug
didnt checked if it still works in the latest SU
sometimes sketchup.exe still exists in the background even if there is no UI. check with a task manager.
-
Works just the same. I now get the 'file already exists/are you sure?' dialog from excel, and if I delay, it will still cause the 'server busy' popup in sketchup. But no Bugsplat. You may want to try xls.close(1), which will always save and not ask. That will avoid the 'server busy' popup.
SU v8M2, Win VistaSP2 64.
-
And no, I did not use any of the 64-bit code you put in the second code window.
-
My Notebook is running Win7-64. It runs exactly the same there. No Bugsplat.
-
Thanks, again!
I should have used 'Save' anyway, as I wanted to update the same file !
Doh!
Strange that you can't break it whatever you do ? -
In the registry there is a "BugSplat" subkey under each versions app key. (Not to be confused with the main "BugSplat" subkey under "Software", that keeps statistics.)
My v7 settings has an DWORD attribute "Enabled" that has the value 0.
There may be a commandline switch to run SU without BugSplat. Perhaps Jim knows?
-
No Bugsplats at all.
Advertisement