Skip to content

Commit 7ba0a80

Browse files
authored
Fixes problem when passing in nullptr for the channel - we need the DiagnosticSink.writer to be nullptr so that we get the buffered result. Unfortunately here, it was set to the default for the channel, which in diagnostics case meant throwing away the diagnostic. (shader-slang#770)
1 parent dbf5f41 commit 7ba0a80

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/slang/slang.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,13 @@ static ISlangWriter* _getDefaultWriter(WriterChannel chan)
400400

401401
void CompileRequest::setWriter(WriterChannel chan, ISlangWriter* writer)
402402
{
403-
writer = writer ? writer : _getDefaultWriter(chan);
404-
m_writers[int(chan)] = writer;
403+
// If the user passed in null, we will use the default writer on that channel
404+
m_writers[int(chan)] = writer ? writer : _getDefaultWriter(chan);
405405

406+
// For diagnostic output, if the user passes in nullptr, we set on mSink.writer as that enables buffering on DiagnosticSink
406407
if (chan == WriterChannel::Diagnostic)
407408
{
408-
mSink.writer = writer;
409+
mSink.writer = writer;
409410
}
410411
}
411412

0 commit comments

Comments
 (0)