I have a GVariant I'm trying to unpack. The variant format string is (uuua(ayay)), and sometimes that a(ayay) is empty. The problem I'm hitting is that if I unpack it and that list is empty, I get an error message of:
GLib-CRITICAL **: g_variant_get_child_value: assertion 'index_ < g_variant_n_children (value)' failed
and it gets stuck printing errors forever. g_variant_get_child_value is getting called from gvariant_get_children in GVariant.hsc, and in this case the n_children is 0.
Here's a thing to reproduce:
import Data.ByteString(ByteString)
import Data.Word(Word32)
import GI.GLib
testData :: (Word32, Word32, Word32, [(ByteString, ByteString)])
testData = (1, 2, 3, [])
unpackTestData :: GVariant -> IO (Maybe (Word32, Word32, Word32, [(ByteString, ByteString)]))
unpackTestData = fromGVariant
main :: IO ()
main = do
variant <- toGVariant testData
type_string <- gvariantGetTypeString variant
putStrLn $ "variant: " ++ show type_string
unpacked <- unpackTestData variant
putStrLn $ "unpacked data: " ++ show unpacked
I have a GVariant I'm trying to unpack. The variant format string is
(uuua(ayay)), and sometimes thata(ayay)is empty. The problem I'm hitting is that if I unpack it and that list is empty, I get an error message of:GLib-CRITICAL **: g_variant_get_child_value: assertion 'index_ < g_variant_n_children (value)' failedand it gets stuck printing errors forever. g_variant_get_child_value is getting called from gvariant_get_children in GVariant.hsc, and in this case the n_children is 0.
Here's a thing to reproduce: