Download it now!
Bug 97231 - QueryValue not working as expected
Summary: QueryValue not working as expected
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.4.7.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Vasily Melenchuk (CIB)
URL:
Whiteboard: target:6.1.0
Keywords: bibisectRequest, regression
Depends on:
Blocks:
 
Reported: 2016-01-18 15:02 UTC by Martin
Modified: 2018-05-23 10:55 UTC (History)
6 users (show)

See Also:
Crash report or crash signature: ["SbxValue::Put(SbxValues const &)"]


Attachments
Backtraces (29.43 KB, text/plain)
2017-03-07 08:06 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin 2016-01-18 15:02:57 UTC
Importwizard - API - QueryValue doesn't return value 

basekey = "Software\Company\AnyKey"

  registryval = QueryValue(HKEY_CURRENT_USER, basekey, "")

Function QueryValue(BaseKey As Long, sKeyName As String, sValueName As String) As Variant
Dim lRetVal As Long         ' Returnvalue API-Call
Dim hKey As Long            ' Onen key handle
Dim vValue As String        ' Key value

    lRetVal = RegOpenKeyEx(BaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    lRetVal = QueryValueEx(hKey, sValueName, vValue)
    RegCloseKeyA (hKey)
    QueryValue = vValue
End Function

lRetVal = RegOpenKeyEx(BaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)

--> hKey is always 0 

With LibreOffice 4.2.7.2 all works fine and hKey is set correctly
Comment 1 Bernhard Scholze 2016-01-21 09:51:40 UTC
Add-On is broken.
Comment 2 Buovjaga 2016-01-26 13:02:05 UTC
How do we test this?

Is the problem still in 5.1?
Comment 3 Martin 2016-01-26 13:25:15 UTC
Yes, the problem is still available in version 5.1.0.2

you could create a new makro in the visual basic editor and run it from there: The following works for me:

Sub Main
Dim sLocTemplatePath as String
Dim sTemplateKeyName as String
Dim sTemplateValueName as String

'sTemplateKeyName = "Software\The Document Foundation\LibreOffice 4.2\StartMenu"
sTemplateKeyName = "Software\The Document Foundation\LibreOffice 5.0\StartMenu"
sTemplateValueName = "swriter.exe"
sLocTemplatePath = QueryValue(HKEY_CURRENT_USER, sTemplateKeyName, sTemplateValueName)
MsgBox ("Path " + sLocTemplatePath) 

End Sub


With LibreOffice 4.2 the key could be read: Result from the MsgBox was "Path 1" and with LibreOffice 5.0 the result from the MsgBox was only "Path "

If you use LibreOffice 5.1 you would have to change the Registry Key Name from 5.0 to 5.1 i think.

best regards
Comment 4 Buovjaga 2016-01-31 12:03:26 UTC
I get an error:
BASIC runtime error.
Sub-procedure or function procedure not defined.

Highlighting this row:
sLocTemplatePath = QueryValue(HKEY_CURRENT_USER, sTemplateKeyName, sTemplateValueName)

Win 7 Pro 64-bit Version: 5.2.0.0.alpha0+
Build ID: 9784ff3d878eaa21491fbd779e57d7d4710f5449
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-01-30_01:31:57
Locale: fi-FI (fi_FI)
Comment 5 Martin 2016-02-01 08:49:49 UTC
i have to open "Object Catalog -> LibreOfficeDev Macros & Dialogs -> ImportWizard - API - QueryValue" once by double clicking and then the macro will find the function procedure.
Comment 6 Buovjaga 2016-02-05 18:43:44 UTC
(In reply to Martin from comment #5)
> i have to open "Object Catalog -> LibreOfficeDev Macros & Dialogs ->
> ImportWizard - API - QueryValue" once by double clicking and then the macro
> will find the function procedure.

Ah, thanks. For testers: this is the dropdown in the macro editor, at the left of Compile and run buttons.

Yeah, I only get
Path

Win 7 Pro 64-bit Version: 5.2.0.0.alpha0+
Build ID: 9784ff3d878eaa21491fbd779e57d7d4710f5449
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-01-30_01:31:57
Locale: fi-FI (fi_FI)
Comment 7 QA Administrators 2017-03-06 14:52:13 UTC Comment hidden (obsolete)
Comment 8 Martin 2017-03-06 15:59:12 UTC
Hello, some bug is still available, this time libreoffce crashes each time i execute my macro.

i have installed the latest version as mentioned in the comment

Version: 5.3.0.3 (x64)
Build ID: 7074905676c47b82bbcfbea1aeefc84afe1c50e1
CPU Threads: 2; OS Version: Windows 6.1; UI Render: default; Layout Engine: new; 
Locale: de-AT (de_AT); Calc: group

i testet my macro with version 4.2.7.2 all works fine

i testet my macro with version 5.3.0.2 nothing happens and libreoffice crashes


The Macro is still the same, as in my first comment
Comment 9 Buovjaga 2017-03-07 06:41:36 UTC
(In reply to Martin from comment #8)
> Hello, some bug is still available, this time libreoffce crashes each time i
> execute my macro.

So this is a new behaviour. You could try getting a backtrace of the crash: https://wiki.documentfoundation.org/How_to_get_a_backtrace_with_WinDbg
Comment 10 Martin 2017-03-07 07:56:41 UTC Comment hidden (obsolete)
Comment 11 Buovjaga 2017-03-07 08:06:00 UTC
Created attachment 131690 [details]
Backtraces

Copied the traces to a .txt file and collapsed the previous comment so this report is not spammed.
Comment 12 QA Administrators 2018-03-08 03:44:23 UTC Comment hidden (obsolete)
Comment 13 Martin 2018-03-08 06:35:58 UTC
Hello,

The Bug is still available in the latest downloadable release version: 

I have testet my macro with LibreOffice 6.0.2.1

Macro:

Sub Main
Dim sLocTemplatePath as String
Dim sTemplateKeyName as String
Dim sTemplateValueName as String

'sTemplateKeyName = "Software\The Document Foundation\LibreOffice 4.2\StartMenu"
'sTemplateKeyName = "Software\The Document Foundation\LibreOffice 5.0\StartMenu"
sTemplateKeyName = "Software\The Document Foundation\LibreOffice 6.0\StartMenu"
sTemplateValueName = "swriter.exe"
sLocTemplatePath = QueryValue(HKEY_CURRENT_USER, sTemplateKeyName, sTemplateValueName)
MsgBox ("Path " + sLocTemplatePath) 

End Sub

Sometimes it crashes, sometimes not as already mentioned in the comment from 2017-03-06 15:59:12
Comment 14 Martin 2018-05-14 08:10:49 UTC
I reproduced the problem with the newest x64 build. Sometimes there is no value returned and sometimes the program crashes.

I uploaded two crash reports:

The crash report was successfully uploaded.
You can soon find the report at:
crashreport.libreoffice.org/stats/crash_details/28b8daca-59ab-415c-af21-f30c8fb56087

The crash report was successfully uploaded.
You can soon find the report at:
crashreport.libreoffice.org/stats/crash_details/9e449638-96b0-437f-aed6-ab44085471b4



Version: 6.0.4.2 (x64)
Build ID: 9b0d9b32d5dcda91d2f1a96dc04c645c450872bf
CPU threads: 1; OS: Windows 10.0; UI render: default; 
Locale: de-AT (de_AT); Calc: group
Comment 15 Commit Notification 2018-05-21 13:42:21 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=de9620dd4539397715dab3102d256f9d634fcb23

tdf#97231: potential crash fixed

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Vasily Melenchuk (CIB) 2018-05-21 13:45:49 UTC
(In reply to Commit Notification from comment #15)
> Vasily Melenchuk committed a patch related to this issue.
> http://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=de9620dd4539397715dab3102d256f9d634fcb23

This is not a final solution, but crash fixed.

Provided script is still not returning correct value from registry.
Comment 17 Commit Notification 2018-05-21 23:09:02 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b9ebabd675f916a0151ec3893a59131f3a8b2a05

tdf#97231: basic: do not use extra wrapping for string marshaling

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.