Skip to content

Commit

Permalink
codegen/object: Don't generate an assertion macro if build has post-p…
Browse files Browse the repository at this point in the history
…rocess
  • Loading branch information
bilelmoussaoui committed Oct 25, 2024
1 parent a172dda commit eeb346b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,17 @@ fn generate_builder(w: &mut dyn Write, env: &Env, analysis: &analysis::object::I
name = analysis.name,
)?;

if env.config.generate_safety_asserts {
writeln!(w, "{}", SafetyAssertionMode::InMainThread)?;
}

// The split allows us to not have clippy::let_and_return lint disabled
if let Some(code) = analysis.builder_postprocess.as_ref() {
// We don't generate an assertion macro for the case where you have a build post-process
// as it is only used to initialize gtk in gtk::ApplicationBuilder which is too early to assert anything
writeln!(w, " let ret = self.builder.build();")?;
writeln!(w, " {{\n {code}\n }}")?;
writeln!(w, " ret\n }}")?;
} else {
if env.config.generate_safety_asserts {
writeln!(w, "{}", SafetyAssertionMode::InMainThread)?;
}
writeln!(w, " self.builder.build() }}")?;
}
writeln!(w, "}}")
Expand Down

0 comments on commit eeb346b

Please sign in to comment.