#!/bin/sh

NEW_UIC=$HOME/dev/qt-512d/qtbase/bin/uic
OLD_UIC=$HOME/dev/qt-512/qtbase/bin/uic

FAILS=""

for U in $(find . -name '*.ui' -type f)
do
    UI=$(echo "$U" | cut -c3-)
    BASENAME=$(basename "$UI" .ui)
    TMP_OLD=/tmp/ui_old_${BASENAME}.h
    TMP_NEW=/tmp/ui_new_${BASENAME}.h
    $OLD_UIC $UI > $TMP_OLD || exit 1
    $NEW_UIC $UI > $TMP_NEW || exit 1
    diff -U 10  $TMP_OLD $TMP_NEW
    EX=$?
    echo $EX $UI 1>&2
    if [ $EX != 0 ]
    then
      FAILS="$FAILS $UI"
    fi
    rm $TMP_OLD $TMP_NEW
done

if [ -n "$FAILS" ]
then
   xjed $FAILS &
fi
