Canvas redraw event hook freezing window
Archives Forums/MaxGUI Bug Reports/Canvas redraw event hook freezing window
| ||
Hi, I've just searched most of the MaxGUI forum and couldn't find an answer to my particular problem. I looked into the maxGUI docs and it mentions that using event hooks is the 'better' way for rendering canvases in the GUI. So I went that route and everything seemed to be fine until I added a window menu. a simple File menu with 'open' and 'new' buttons on it, once clicked, freezes the whole app. It seems like the canvas is getting redrawn when the file menu is rendering over it, but somehow gets stuck in an endless loop? below is the source that triggers this issue on my windows XP machine: SuperStrict Import maxgui.win32maxguiex Type TEditor Field _window:TGadget Field _canvas:TGadget Global _timer:TTimer Const MENU_NEW:Int = 101 Const MENU_OPEN:Int = 102 Const MENU_CLOSE:Int = 103 Const MENU_EXIT:Int = 104 Method New() Local width:Int = 1024 Local height:Int = 768 _window = CreateWindow("Editor", 20, 20, width, height) _canvas = CreateCanvas(0, 30, width, height, _window) _canvas.SetLayout(1, 1, 1, 1) _InitGui() End Method Function eventhook:Object(id:Int, data:Object, context:Object) Local event:TEvent Local app:TEditor event = TEvent(data) app = TEditor(context) If event.id = EVENT_GADGETPAINT Or event.id = EVENT_TIMERTICK Then app.OnEvent event Return Null End If return event End Function Method OnEvent(event:TEvent) Select event.id Case EVENT_TIMERTICK RedrawGadget(_canvas) Case EVENT_GADGETPAINT If(event.source = _canvas) Then DebugLog "test" SetGraphics CanvasGraphics(_canvas) Cls() DrawRect(100, 100, 300, 300) Flip() End If End Select End Method Function Run() Local ed:TEditor = New TEditor AddHook EmitEventHook, ed.eventhook, ed ed._timer = CreateTimer(60) While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End End Select Wend End Function Method _InitGui() 'main menu Local mainMenu:TGadget = WindowMenu(_window) Local fileMenu:TGadget = CreateMenu("&File", 1, mainMenu) CreateMenu("&Open", MENU_OPEN, fileMenu) CreateMenu("&New", MENU_NEW, fileMenu) UpdateWindowMenu(_window) End Method End Type TEditor.Run() am I doing something wrong? |
| ||
Are you on Windows XP? It appears to work OK here on my Vista PC? Also, what happens when you switch to the older MaxGUI.Win32MaxGUI driver instead of MaxGUI.Win32MaxGUIEx? |
| ||
Works on my XP here with both drivers! |
| ||
When i switch to MaxGUI.Win32MaxGUI it seems to work better, but still some oddities. If I bring up the 'file menu' with the win32maxgui drive my mouse begins to stutter just like with the ex driver (except to a less extent), and my CPU spikes up to 100%. Yet I'm still able to select the menu items. With the ex driver my CPU spikes to 100% and I never get control back of the app. I'm on windows XP home with dual monitors if that's any help. *EDIT* I just tested this same code on a vista laptop and it worked fine. |
| ||
The canvas is frozen here. I am using BRL.Win32MaxGUI. The debug log says that it is drawing, but I can clearly see it isn't. I've also been having trouble with my canvas listbox that I stopped working on because it kept freezing and made me keep terminating the process. |
| ||
SebHoll, any updates on this or work arounds? |
| ||
Errrrmmmmm... No, sorry. I just borrowed my brother's XP PC to test the sample code you provided, and I can't get it to lock up when I open the menu (or by doing anything else neither), which makes bug squishing extremely difficult. Does it lock if you use an event queue instead? Also, is there anything specific about your computer set-up? For example, are you using a non-English version of Windows? Are you using Windows Classic window theme or the standard XP ones? Are you using Windows Blinds or some other patched theme manager? Finally, what happens if you comment out RedrawGadget() from EVENT_TIMERTICK? Does it still lock-up? Edit: I've moved this to the MaxGUI Bug Reports forum for now, so I can keep a closer eye on it. |
| ||
Line 30 is causing the problem. Why are you forcing a redraw with a timer? There seems to be an OpenGL drawing error where the viewport is not resized with the canvas. In my engine this does not occur because I am doing the rendering myself, so that indicates it is an error in BRL.GLGraphics. |
| ||
Isn't line 30... If event.id = EVENT_GADGETPAINT Or event.id = EVENT_TIMERTICK Then Not sure why that would be causing an error... Can you post the line you mean, Leadwerks? |
| ||
Yes that is what I mean. It causes RedrawGadget(_canvas) to be called, which causes a new render. |
| ||
SebHoll, Does it lock if you use an event queue instead? when just using the event queue it functions correctly. Also, is there anything specific about your computer set-up? For example, are you using a non-English version of Windows? Are you using Windows Classic window theme or the standard XP ones? Are you using Windows Blinds or some other patched theme manager? I am running Microsoft's Zune theme (an official windows theme, not some 3rd party skinning app), I had only reformatted about a month ago so there isn't much software on it. I switched it back to XP theme to test and the results are the same. It's the english version of XP. The only thing I would consider 'non-standard' about my physical setup is I have dual monitors (24-inch and a 19 inch). I disabled one of the monitors and had only one running and that didn't affect anything. Finally, what happens if you comment out RedrawGadget() from EVENT_TIMERTICK? Does it still lock-up? using the original eventHook code posted above, if I comment out 'redrawGadget' from EVENT_TIMERTICK then my canvas only draws once (upon load), which is to be expected right? There's no lock up in this situation. |