1. How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 09, 2011
- 37636 views
In a large program, when I use:
getFontSize (WinMain)
or
setFont (PREVIEW,fontSize,Normal)
After using a few times (no problem), suddenly I get the error message:
Error code 425 LOGIC ERROR: Held resource owner is not the current owner.
Sorry for being annoying with many problems. It's because I'm migrating some development programs for the EU403, and many problems are appearing.
I can solve some, but others not, like this one, it is very difficult.
What is causing this? How can I fix?
Thanks a lot
Sergio
2. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 09, 2011
- 37600 views
Hello, me again....and solution problem...?????
I am using "Courier" in the main window.
I also use this font in a secondary window where there is option to change the font size and show the result.
I did a test, using the font "Arial" in the secondary window and the error message no longer appears.
This means that WIN32LIB does not allow to use the same font in different windows with different sizes?
3. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Oct 09, 2011
- 37609 views
This means that WIN32LIB does not allow to use the same font in different windows with different sizes?
The library does allow that so there must be something else going on. If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
In the meantime, I'll try to reproduce on my system, the problem you describe.
4. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 09, 2011
- 37633 views
If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
In the meantime, I'll try to reproduce on my system, the problem you describe.
Small code sample to isolate the problem?
I tried this.
But when the code is separated into a small program, the problem also appears. But it happens very rarely.
The program that is having this problem is very large, but the error occurs in only a small include.
And the error only appears after about 3 or 4 times with good results
If you wish, I send you the total program. sergio@audiophoto.com.br
Sergio
5. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 11, 2011
- 37530 views
- Last edited Oct 12, 2011
If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
Sorry, this is the smallest "code" I could do.
He is configured to do the error mentioned
Attention to the lines enveloped between the lines equal to this
------------*******************************************------------ code lines ------------*******************************************------------
is where the problem can be solved or created
include Win32lib.ew global integer fontSize,hasOptionsChanged hasOptionsChanged=-1 -------------------------------------------------------------------------------------------------- fontSize=12 constant fontsizelist ={20,8,9,10,11,12,13,14,15,16,17,18,19,20} ,fontname="Courier New" -- tem que usar esta fonte ------------------------------------------------------------------------------- global constant MAIN = create( Window, "MAIN Window ", 0, 120, 70, 900, 600, 0) ,MLE = create( LText, "", MAIN, 222, 111, 510, 220, 0 ) -- MLE = janela de edicao ,OPTIONSWINDOW = create( Window, "Options", MAIN, 20, 370, 600, 400,{ WS_DLGFRAME, WS_SYSMENU}) ,FONTSIZELIST =create( List, "Font Sizes", OPTIONSWINDOW, 280, 20, 45, 75, 0 ) ------------------------------------------------------------------------------------ procedure writeAnyThing(atom id, atom sz, sequence text) setPenColor( id, 4 ) setFocus(id) setVisible(id,1) setFont(id, fontname, sz, Normal) ------------*******************************************------------ -- This below line, solve the problem , but I need the "Courier New" -- if id=MLE then setFont(id, "Arial", sz, Normal) end if ------------*******************************************------------ wPuts(id,text) end procedure ------------------------------------------------------------------------------------ procedure paint_preview() -- entirely re-create preview panel using current values sequence data integer fontwidth, fontheight data = getFontSize(OPTIONSWINDOW) data = getFontSize(MLE) fontwidth = data[1] fontheight = data[2] setPosition(MLE ,0,0) setIndex(MLE,1) setWindowBackColor(MLE, BrightWhite) writeAnyThing(MLE,fontSize," Ia Ia Ia Ia Ia Ia Ia Ia ") setWindowBackColor( OPTIONSWINDOW, BrightWhite) setPosition(OPTIONSWINDOW ,10,100) writeAnyThing(OPTIONSWINDOW,fontSize,"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ") end procedure ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- function get_fontsize() integer junk junk = getIndex(FONTSIZELIST) if not junk then return fontSize else return fontsizelist[junk] end if end function ------------------------------------------------------------------------------- global procedure showsResultAfterSelectingFont(integer x, integer y, sequence z) fontSize = get_fontsize() -- get fontSize selected paint_preview() end procedure --------------- setHandler(FONTSIZELIST, w32HChange,routine_id("showsResultAfterSelectingFont")) ------------------------------------------------------------------------------- global procedure on_open_OPTIONS(integer x, integer y, sequence z) eraseItems ( FONTSIZELIST ) for i = 1 to length(fontsizelist) do addItem( FONTSIZELIST, sprintf("%d", fontsizelist[i]) ) end for showsResultAfterSelectingFont(0,0,"") end procedure -------------------------------------------------------------------------------- setHandler(OPTIONSWINDOW, w32HOpen,routine_id("on_open_OPTIONS")) ------------*******************************************------------ -- here (below) happens the error setHandler(OPTIONSWINDOW, w32HPaint,routine_id("showsResultAfterSelectingFont")) -- You can comment the line above, but the window "MLE" do not -- will show words when open in the first time ------------*******************************************------------ -------------------------------------------------------------------------------- procedure closeOPTIONSWINDOW(integer x, integer y, sequence z) hasOptionsChanged=0 setFocus(MLE) setVisible(MLE,0) setPosition(MLE,10,10) setIndex(MLE,30) writeAnyThing(MLE,30,"final do programa ") end procedure --------------------------------------------------------------------------------- setHandler(OPTIONSWINDOW, w32HClose,routine_id("closeOPTIONSWINDOW")) --------------------------------------------------------------------------------- function OptionsHaveChanged() integer temp openWindow(OPTIONSWINDOW, Normal) while 1 do doEvents(0) -- allows other events SetHandler to work if hasOptionsChanged != -1 then -- otherwise will be in eternal loop closeWindow(OPTIONSWINDOW) temp = hasOptionsChanged hasOptionsChanged = -1 return temp end if end while end function --------------------------------------------------------------------------------- procedure onClickMain(integer x, integer y, sequence z) x=OptionsHaveChanged() -- stands still here, even the program to return this function end procedure --------------------------------------------------------------------------------- setHandler(MAIN, w32HClick,routine_id("onClickMain")) --------------------------------------------------------------------------------- procedure onOpenMain(integer x, integer y, sequence z) setWindowBackColor( MLE, BrightWhite) setFont( MAIN, "Courier New", 20, Bold ) setFont( MLE, "Arial", 20, Bold ) setPosition(MAIN,10,10) writeAnyThing( MAIN, 20, "Click on anywhere gray color of the window" ) end procedure ------------------------------------------------------------------------------------- setHandler(MAIN, w32HPaint,routine_id("onOpenMain")) WinMain( MAIN,Normal )
6. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by mattlewis (admin) Oct 11, 2011
- 37502 views
If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
Sorry, this is the smallest "code" I could do.
I haven't run your code or examined it in detail, but I think that you should probably not have that infinite loop in there. Is there a reason for doing that instead of simply handling the event when it needs to be handled?
I'm guessing that you really want the options window to be modal. I'm pretty sure there's a way to do that in Win32Lib (been a while, so I don't recall how off the top of my head).
Matt
7. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 11, 2011
- 37514 views
If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
Sorry, this is the smallest "code" I could do.
I haven't run your code or examined it in detail, but I think that you should probably not have that infinite loop in there. Is there a reason for doing that instead of simply handling the event when it needs to be handled?
I'm guessing that you really want the options window to be modal. I'm pretty sure there's a way to do that in Win32Lib (been a while, so I don't recall how off the top of my head).
Matt
I'm using this "infinite loop" to keep a semblance of the code (much greater)I'm having problems.
8. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by Euman_Overman Oct 11, 2011
- 37464 views
You are overwriting 'data' w/o using it and I'm not sure why You're making needless calls and insertions
data = getFontSize(OPTIONSWINDOW) data = getFontSize(MLE)
Regards, Euman
9. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 11, 2011
- 37479 views
You are overwriting 'data' w/o using it and I'm not sure why You're making needless calls and insertions
Euman
The above was done to try to reproduce an environment where we get an error "code 425"
This error can occur in lines that have instructions like these:
getFont ()
setFont ()
This is why I used them more than once.I know it seens stupidity
Please keep in mind that this code is just a small summary of a much larger code,
I summarized it, to facilitate the vision of where the error occurs.
But to generate the error, I need to keep statements that seem unnecessary here.
That's not what Derek request to analyze the error?
Do not think it strange that the error does not occur when using a different font in a MLE window?
Sergio
10. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Oct 11, 2011
- 37457 views
Sorry, this is the smallest "code" I could do ...
I have not had a chance to look at it yet but I will test your code tonight, in about 8 hours from now.
11. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Oct 12, 2011
- 37368 views
I think I have a solution. Can you please try this and let me know if it works for you.
You need to change one of the win32lib include files. In the file w32resources.ew, in the procedure called traceObject, find the line ...
if heldResource[at][ResOwner] = owner then
and change it to ...
if heldResource[at][ResOwner] = owner or heldResource[at][ResObjType] = kFontObject then
Also, instead of the "while 1" loop you should consider using openDialog() to open the options window. This will keep focus on the options window until the user closes it.
12. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 12, 2011
- 37337 views
I think I have a solution. Can you please try this and let me know if it works for you.
After modifying the file "w32Resources.ew," according to their instructions, the "error425" no longer occurred
Thank you, to this solving this problem and especially for you heed, my explanations that I do with many faults of language English
Also, instead of the "while 1" loop you should consider using openDialog() to open the options window. This will keep focus on the options window until the user closes it.
I need "a while ..." because I made a dialog box that captures the parameters used in the fonts and some others that are not in function "OpenDialog ().
Do you think "a while ..." is a bad feature?
Sergio
13. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Oct 13, 2011
- 37291 views
I need "a while ..." because I made a dialog box that captures the parameters used in the fonts and some others that are not in function "OpenDialog ().
Do you think "a while ..." is a bad feature?
No exactly bad but unnecessary. Here is what your routine could look like ...
function OptionsHaveChanged() integer temp openDialog(OPTIONSWINDOW) temp = hasOptionsChanged hasOptionsChanged = -1 return temp end function
14. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by mattlewis (admin) Oct 13, 2011
- 37307 views
Also, instead of the "while 1" loop you should consider using openDialog() to open the options window. This will keep focus on the options window until the user closes it.
I need "a while ..." because I made a dialog box that captures the parameters used in the fonts and some others that are not in function "OpenDialog ().
Do you think "a while ..." is a bad feature?
In general, yes. Windows provides your program with events that will call back to your program. While waiting for an event, your program basically does nothing. With the while loop, your program will eat up a lot of processor time without really doing anything. Letting Windows handle that job is much more efficient.
Matt
15. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 13, 2011
- 37261 views
Derec and Matt, thank you very much, resolved all the issues I posted here.
Sergio
16. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Jan 05, 2013
- 36351 views
I think I have a solution. Can you please try this and let me know if it works for you.
You need to change one of the win32lib include files. In the file w32resources.ew, in the procedure called traceObject, find the line ...
if heldResource[at][ResOwner] = owner then
and change it to ...
if heldResource[at][ResOwner] = owner or heldResource[at][ResObjType] = kFontObject then
Also, instead of the "while 1" loop you should consider using openDialog() to open the options window. This will keep focus on the options window until the user closes it.
Hello Derek
I had to reinstall the system files Euphoria, and found that the above problem has not been solved.
Does no one else need this feature? :)
Sergio
17. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Jan 06, 2013
- 36257 views
I had to reinstall the system files Euphoria, and found that the above problem has not been solved.
But did you also try my suggested fix?
18. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Jan 07, 2013
- 36169 views
But did you also try my suggested fix?
Yes, I used your suggestion and now everything works fine.
Just do not think it is normal to corrupt an original file, for my programs work.
What is wrong with my code?
19. Re: How to solve LOGIC ERROR: Held resource owner
- Posted by DerekParnell (admin) Jan 07, 2013
- 36150 views
What is wrong with my code?
Nothing that I can see. The fault was in my code inside win32lib.ew. Now that you have tried my suggestion and it works, I can permanently fix the library with this tested fix.