Jump to content

  • Log In with Google      Sign In   
  • Create Account


Jan2go

Member Since 14 Dec 2013
Offline Last Active Today, 05:17 AM
-----

Topics I've Started

Passing shared_ptr between modules

25 May 2014 - 04:43 AM

I have a singleton class (EventManager) in a static lib that gets linked by both the .exe and a dynmic lib. Events are passed around as std::shared_ptr<IEvent>. The EventManager stores all queued events in a std::list and pops them out after handling them. This works fine as long as all events were added from the exe. If I add events from inside the DLL, pop_front throws an exception at the last event that was added from inside the DLL. It doesn't matter whether the DLL adds one event or 1000, only the one that was added last throws the exception.

This is the exception:

Debug Assertion Failed!

Program: ...ts\visual studio 2013\Projects\QueueTest\Debug\DynamicLib.dll
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
Line: 1424

Expression: _pFirstBlock == pHead

I'm using the Visual Studio 2012 with compiler for this.

I know that you should not deallocate memory in any module other than the one that allocate the memory. However, from what I've read std::shared_ptr can be used to avoid this problem as it contains a pointer to the deleter for the memory.

 

I attached a sample project with this problem to this post.

 

Any ideas on how I can get the EventManager to work with events coming from a DLL?


[GLEW] Check available OpenGL version

19 May 2014 - 10:22 AM

The GLEW documentation states that you can check the available OpenGL version like this:

if (GLEW_VERSION_1_3)
{
  /* Yay! OpenGL 1.3 is supported! */
}

So, as my code is using OpenGL 3.0 i used GLEW_VERSION_3_0 to see if the computer can run the program. However, when I tested it on an Thinkpad which uses an integrated Intel graphics card with support only up to OpenGL 2.1. GLEW_VERSION_3_0 was for some reason evaluated as true. Querying GL_MAJOR_VERSION and GL_MINOR_VERSION as well as GL_VERSION show the correct result (OpenGL 2.1).

I tested other GLEW_VERSION_X_X macros on this computer, you can see the results in the attached file.

 

Has anybody else experienced this before? It's not a big deal to create a workaround for it but I wonder what might cause it and if it happens on other graphic cards as well.


PARTNERS