Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access violation in the sample program #17

Open
GoogleCodeExporter opened this issue Apr 11, 2015 · 0 comments
Open

Access violation in the sample program #17

GoogleCodeExporter opened this issue Apr 11, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

the following function in your sample application causes a access violation, 
because g_broker == 0;

void PaintMainWindow(HDC dc, PAINTSTRUCT* /*ps*/) {
...
  ::wsprintfW(buf, L"worker file calls : %ld", g_broker->GetNumCallsPerArea(Broker::FILES));
...
}

this function is triggered by calling CreateMainWindow in BrokerMain.
The broker instance is created after CreateMainWindow, therefore when 
PaintMainWindow first gets called, g_broker is still empty.

int BrokerMain(HINSTANCE instance, const wchar_t*) {
  HWND win = CreateMainWindow(instance);
  if (!win) {
    return -1;
  }
  Broker broker(win);
  broker.SetPolicy(Broker::FILES, true);
  broker.SpawnWorker(kWorkerCmdline);
  g_broker = &broker;
...
}

This issue is reproducible with vs2012 on win8. for now, I'm doing this:

if (g_broker)
  ::wsprintfW(buf, L"worker file calls : %ld", g_broker->GetNumCallsPerArea(Broker::FILES));

Original issue reported on code.google.com by [email protected] on 1 Oct 2013 at 4:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant