<div dir="ltr">(Oh sorry I'll copy it down)<div><br></div><div><span style="font-size:12.8px">What I'm doing is pretty straight forward. I haven't changed the vtk code at all.</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>vtkDirectory * sourceDir = vtkDirectory::New();</div><div>sourceDir->Open(sourceString.<wbr>c_str());</div><div>vtkSortFileNames * sourceFiles = vtkSortFileNames::New();</div><div>sourceFiles-><wbr>SkipDirectoriesOn();</div><div>sourceFiles->NumericSortOff();</div><div>sourceFiles-><wbr>SetInputFileNames(sourceDir-><wbr>GetFiles());</div><div>sourceFiles->Update();</div><div><br></div></div><div style="font-size:12.8px"><div>for (int i = 0; i < targetArray-><wbr>GetNumberOfValues(); i++)</div><div>{</div></div><div style="font-size:12.8px"> string s1 = sourceFiles->GetFileNames()-><wbr>GetValue(i); // crash!</div><div style="font-size:12.8px">}</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks</div><div style="font-size:12.8px">Ollie</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 September 2016 at 00:02, David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You forgot to reply all to keep the discussion on the mailing list for posterity.<br></div><div class="gmail_extra"><span class=""><br clear="all"><div><div data-smartmail="gmail_signature">David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4909</div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On Fri, Sep 2, 2016 at 2:17 AM, Oliver Cairncross <span dir="ltr"><<a href="mailto:op.cairncross@gmail.com" target="_blank">op.cairncross@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What I'm doing is pretty straight forward. I haven't changed the vtk code at all.<div><br></div><div><div>vtkDirectory * sourceDir = vtkDirectory::New();</div><div>sourceDir->Open(sourceString.c<wbr>_str());</div><div>vtkSortFileNames * sourceFiles = vtkSortFileNames::New();</div><div>sourceFiles->SkipDirectoriesOn<wbr>();</div><div>sourceFiles->NumericSortOff();</div><div>sourceFiles->SetInputFileNames<wbr>(sourceDir->GetFiles());</div><div>sourceFiles->Update();</div><div><br></div></div><div><div>for (int i = 0; i < targetArray->GetNumberOfValues<wbr>(); i++)</div><div>{</div></div><div> string s1 = sourceFiles->GetFileNames()->G<wbr>etValue(i); // crash!</div><div>}</div><div><br></div><div>Thanks</div><div>Ollie</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 2 September 2016 at 13:45, David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Whatever your sourceFiles->GetFileNames object has uninitialized pointers.<br><br>Debug mode initializes all values to 0, release does not (in order to save run time), but this leaves you with some pointer pointing to nonsense.<br><br><br></div><div class="gmail_extra"><br clear="all"><div><div data-smartmail="gmail_signature">David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: <a href="tel:518-881-4909" value="+15188814909" target="_blank">518-881-4909</a></div></div>
<br><div class="gmail_quote"><div><div>On Thu, Sep 1, 2016 at 11:32 PM, Oliver Cairncross <span dir="ltr"><<a href="mailto:op.cairncross@gmail.com" target="_blank">op.cairncross@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi,<div><br></div><div>vtk 7, msvc 14, windows 10<br><div><br></div><div>I've had this problem before and thought it was something bad in my tool chain. But I've rebuild everything from scratch and it's still a problem.</div><div><br></div><div>If I do something simple like</div><div><br></div><div>string s1 = sourceFiles->GetFileNames()->G<wbr>etValue(i);<br></div><div><br></div><div>it runs fine in debug mode. When I compile in RelwithDebInfo it crashes with a bad allocation.</div><div>When I have a look at the object the there is garbage where the string is supposed to be. As if it hasn't been initialised. I am calling an sourceFiles->Update() beforehand.</div><div><br></div><div>Interestingly if I do</div><div><br></div><div>cout << sourceFiles->GetFileNames()->G<wbr>etValue(i);</div><div>string s1 = sourceFiles->GetFileNames()->G<wbr>etValue(i);<br></div><div><br></div><div>it will print to console and then crash on the next line.</div><div><br></div><div>Is anyone else having this problem?</div><div><br></div><div>Cheers</div><div>ollie</div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>