[vtkusers] Trouble using vtkAxis->SetTitle
Frese Daniel Dr.
frese at heidenhain.de
Thu May 5 04:26:49 EDT 2011
Hi Riku,
Thank you for your answer. Yes you are right; as soon as I build the Debug version
and link my Debug build with this, it runs fine. This is really unexpected for me !
As I said, I have been working with vtk now quite for a while without ever building an
explicit Debug version.
Now my question would be towards the vtk (Windows-) developers, whether this behavior
is known and/or expected, and how to deal with it.
For me, this means I have to have two sets of the
vtk system now while developing software. Most of the time I develop using
the Debug configuration (for obvious reasons), but regularly I build also
Release versions. As mentioned before, the Debug config seems to be a bit
more "forgiving", such that some nasty bugs within my application
don't show up in the Debug config but crash randomly the Release
(mostly pointer/memory related stuff...).
The problem now seems to be, that the Debug and Release versions of the
files use the same name and the cmake-generated target INSTALL in the
Visual Studio copies everything into the same directories. So having
two discrete sets of the dlls on the same machine does not seem to be
supported by the installation process right now. I can try to solve
this by manually copying files around (and link my app to the right
stuff, depending to the chosen config), but is there a better solution ?
Or, to phrase the question differently, is an automated side-by-side
configuration for debug and release versions possible ?
Thanks,
Daniel
-----Ursprüngliche Nachricht-----
Von: kotiranta at gmail.com [mailto:kotiranta at gmail.com] Im Auftrag von Riku
Gesendet: Mittwoch, 4. Mai 2011 22:53
An: Frese Daniel Dr.
Cc: Marcus D. Hanwell; vtkusers at vtk.org
Betreff: Re: [vtkusers] Trouble using vtkAxis->SetTitle
Hello Daniel,
I recently had this very same problem. I also for some reason was
fiddling about with the vtkStdString initially -- unnecessarily. Now I
successfully use code very similar to you testing code below, in loads
of places.
You already hit the point in you mail, I think: it's about the
versions of the DLLs. I've found through experience that Debug builds
of my software need to be used together with Debug builds of VTK DLLs,
Release builds together with Release DLLs, etc. After making sure that
the builds of my software and the VTK DLLs match, I have no further
problems.
I hope this solves your issue. (Please let me know if so, or if not.)
Good luck,
Riku
2011/5/4 Frese Daniel Dr. <frese at heidenhain.de>:
> Hi Marcus,
>
> I simplified as much as I could. Here is the crashing
> program :
>
> #include "vtkAxis.h"
> #include <string>
>
> void main() {
> std::string temp = "TestX";
>
> vtkAxis *Xaxis = vtkAxis::New();
> Xaxis->SetTitle(temp.c_str());
> }
>
> It crashes at the same line in vtkAxis.cxx as I wrote before.
>
> Testing a bit further, I noted that the program crashes only when built and
> run in Debug configuration, but it runs fine in Release. I am aware that in the
> Visual Studio Debug and Release versions can behave differently, but in my experience
> so far the Debug configuration was always more benign than the Release. So I had a few
> times the case that the Release version crashes while the Debug ran fine;
> but this time it's the other way around ?!
>
> The only lib I link for this test program is vtkAxis (although the behavior does not
> change when linking also other vtk libs additionally). I use in both cases (Debug and
> Release) the same vtkAxis.dll (built with the same compiler MSVC 2008 in "RelWithDebInfo" Config).
> Is this OK or do I have to built a second set of Debug libs for use in programs built
> in the Debug config ? Maybe this whole thing has nothing to do with vtkAxis, but is just a
> MSVC thing. On the other hand I've been working with vtk for a few months now and never built any
> Debug version of the lib, and is has been working fine so far...
>
> If anybody could shine some light on this, this would be great. I can also post/send a ZIP of the
> MSVC solution, but since this is about 400kB, I'd rather not "pollute" the whole mailing list with
> such an attachment. The program above is basically the main.cpp of a Win32 console application
> without any further whistles and bells.
>
> Daniel
>
> -----Ursprüngliche Nachricht-----
> Von: Marcus D. Hanwell [mailto:marcus.hanwell at kitware.com]
> Gesendet: Dienstag, 3. Mai 2011 16:31
> An: Frese Daniel Dr.
> Cc: vtkusers at vtk.org
> Betreff: Re: [vtkusers] Trouble using vtkAxis->SetTitle
>
> 2011/5/3 Frese Daniel Dr. <frese at heidenhain.de>:
>> Hi !
>>
>> I am having some strange problem using vtkAxis->SetTitle() from the new
>> charts API.
>> After the second of the following lines an exception occurs:
>>
>> temp = XAxisName->c_str();
>> Xaxis->SetTitle(temp); // title of axis
>
> What is XAxisName, and std::string? There is no need for the temp, but
> you could use it (vtkStdString can be constructed in the function from
> a const char* that is properly null terminated).
>>
>> Temp is of type vtkStdString and Xaxis of type vtkSmartPointer<vtkAxis>
>> (although the behavior is essentially the same when I make Xaxis as a direct
>> vtkAxis without any smart pointers).
>> I checked that the value of temp at this point is well defined ("TestX"),
>> and I can trace further until I arrive at
>> void vtkAxis::SetTitle(const vtkStdString &title)
>> {
>> if (this->Title != title)
>> {
>> this->Title = title;
>> this->Modified();
>> }
>> }
>>
>> , which is defined in vtkAxis.cxx. The exception occurs when trying to
>> execute the line this->Title = title;
>> The odd thing - already indicating that something goes wrong - is that
>> "title" seems to point four bytes before the right string and seems to be
>> much longer; i.e. it shows XXXXTestXXXXXX., where X is some arbitrary
>> garbage byte.
>>
>> I am using Visual Studio 2008 on Win XP and get an exception message stating
>> some memory corruption.
>>
>> Does anybody has a clue what's going on here ? If I remove calls to SetTitle
>> (I have two of them in my app), everything seems to run smoothly (apart from
>> the missing labels of course).
>>
> I have not seen this, if you can create a minimal test case that
> reproduces the error I could take a look. Maybe our Windows developers
> have a better idea, but the VTK tests run regularly on Windows and set
> the axis title using a const char *, which then uses the const char *
> constructor to make a temporary vtkStdString.
>
> Marcus
>
>
> -------------------------------------------------------------------------------------------------------
> Registergericht: Traunstein / Registry Court: HRB 275 - Sitz / Head Office: Traunreut
> Aufsichtsratsvorsitzender / Chairman of Supervisory Board: Rainer Burkhard
> Geschäftsführung / Management Board: Thomas Sesselmann (Vorsitzender / Chairman),
> Michael Grimm, Matthias Fauser, Sebastian Tondorf
>
> E-Mail Haftungsausschluss / E-Mail Disclaimer: http://www.heidenhain.de/disclaimer
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list