Perhaps i did something wrong?
patching file wxsdrawingwindow.cpp
Hunk #1 FAILED at 82.
Hunk #2 succeeded at 110 (offset -1 lines).
Hunk #3 FAILED at 158.
Hunk #4 succeeded at 250 (offset -1 lines).
patch: **** malformed patch at line 78: Index: wxsdrawingwindow.h
i applied it to the file as it is in svn, rev 4011
hmm paint is called first, then erase. on screen, I see the button appear as repaint is called and disappear as erase is called. If it normal that erase is called now?
void OnEraseBack(wxEraseEvent& event)
well it's empty - I'm just not sure I get how wxSmith displays widgets. Does it use some sort of screen capture?
Yes, exactly, the screen is captured and the extra content is drawn over it.
And I thing that we have the reason of hiding content - it looks like this empty erase function is responsible for this. Could you comment line 96:
Connect(DrawingPanelId,wxEVT_ERASE_BACKGROUND,(wxObjectEventFunction)&wxsDrawingWindow::DrawingPanel::OnEraseBack);
And check what will happen?
Regards
BYO
Hmm, another thing that came into my mind:
Could you put on line 292? :
void wxsDrawingWindow::FetchSequencePhase2()
{
if ( !Panel ) return;
if ( IsDestroyed ) return;
FetchScreen();
HideChildren();
Panel->Show();
DuringFetch = false;
FastRepaint(); // <----
}
and maybe other solution for this problem:
void wxsDrawingWindow::FetchSequencePhase2()
{
if ( !Panel ) return;
if ( IsDestroyed ) return;
FetchScreen();
HideChildren();
DuringFetch = false; // <--- This and
Panel->Show(); // <--- this line were swapped
}
Maybe it's just as you say that children are hidden, panel is shown but it doesn't paint.
It may not paint because DuringFetch is still false. On Win and Linux, Panel->Show causes some extra event to be generated and paint procedure is actually done after jumping out of FetchSequencePhase2(). On Mac it may be done while calling Show function.
Regards
BYO
I tried both with still no luck :?
HOWEVER, i made a little experiment that most likely shows the issue.
i added
if(!Bitmap->SaveFile(wxT("wxSmithScreen.bmp"),wxBITMAP_TYPE_BMP)) std::cout << "saving failed" << std::endl;
at the end of FetchScreen(). I then opened wxSmith, then opened the generated file - and it was empty (transparent). So it seems like fetchScreen() doesn't work.
I tried both with still no luck :?
HOWEVER, i made a little experiment that most likely shows the issue.
i added
if(!Bitmap->SaveFile(wxT("wxSmithScreen.bmp"),wxBITMAP_TYPE_BMP)) std::cout << "saving failed" << std::endl;
at the end of FetchScreen(). I then opened wxSmith, then opened the generated file - and it was empty (transparent). So it seems like fetchScreen() doesn't work.
Hmm, doesn't look very optimistic :(. But there is a way to fetch screen since splashscreen uses this. Maybe the screen is fetched in wrong time or maybe it's fetched properly but cleared right after :/
Could you check this code instead of the one you presented ? It will save each fetch at different bitmap and show number of fetches made. If at least one bitmap will have valid content, it would be huge milestone. There will also be a hint how many fetches are done after each change (it will put number of fetches done so far into stdout). The correct behavior would be to fetch only once after each resource change / editor content resize.
static int Cnt = 0;
if(!Bitmap->SaveFile(wxString::Format(wxT("wxSmithScreen%d.bmp"),++Cnt),wxBITMAP_TYPE_BMP)) std::cout << "saving failed" << std::endl;
std::cout << "fetch " << Cnt << std::endl;
Regards
BYO
Thanks for leading me - guess what? I have a fix!!!
void wxsDrawingWindow::FetchScreen()
{
if ( !Bitmap ){ return; }
wxYield(); // <-----
// Fetching preview directly from screen
wxScreenDC DC;
As simple as that :lol: now i don't say it fixes everything, but it fixes the most obvious bug. apparently wx just didnt have time to draw before you got the screen capture. maybe it would be better to call for redrawing the window instead of yield.
BTW What's wrong with autotools?? i need to issue the make command several times in a row as it randomly crashes or fails even though the code is valid. just reissuing it many times in a row fixes the problems...
I get seemingly randomly
/bin/sh: line 1: make: No such file or directory
ranlib $ d
ranlib: can't open file: $ (No such file or directory)
ranlib: can't open file: d (No such file or directory)
Thanks for leading me - guess what? I have a fix!!!
void wxsDrawingWindow::FetchScreen()
{
if ( !Bitmap ){ return; }
wxYield(); // <-----
// Fetching preview directly from screen
wxScreenDC DC;
As simple as that :lol: now i don't say it fixes everything, but it fixes the most obvious bug. apparently wx just didnt have time to draw before you got the screen capture. maybe it would be better to call for redrawing the window instead of yield.
Wow, thanks for all your investigations :) Now we really have something 8)
That's funny because I've used Yields before switching to timers :? Maybe some unique combination: first call timer, than yield is the only available solution. But just to make sure: there's small inline function at the beginning of wxsdrawingwindow.cpp:
inline RepaintDelayType GetDelayType()
{
// Looks like this gives best results so far on both linux and windows
return TimerNormal;
}
If you change it's content to return Yield; it will use yields instead of timers. Can you check if this works ? (It shouldn't because it didn't worked ealier).
Anyway, I'd like to avoid calling Yields because it can lead to some rare crashes, expecially when editor is being closed. And there's only one solution that come into my mind now: just call Refresh right before Update in OnFetchSequence (line 236). I assumed that refresh request is sent automaticaly after show/hide stuff, but obviously it was a bad assumption. I'll see how it works on other oses, maybe it's possible to avoid any timer/yield stuff.
Regards
BYO
Hi Byo,
your code works as well. When using this code components do not disappear. (they do disappear when trying to play with them e.g. clicking on a text area to add text in it but i think it did it with my other code too)
so it looks like
#ifdef __WXMAC__
return Yield;
#else
return TimerNormal;
#endif