Sorry to take so long answering this! Selznick had to cut a deal, since MGM didn’t like loaning their actors, and part of that was Selznick paying Gable while MGM/Loew’s Inc. provided the budget and in name released GWTW. Vivien Leigh was actually under contract to a British filmmaker named Alexander Korda, but they worked it out since David’s brother, Myron Selznick, was connected to her representative agency or something like that.
Anyways, as for Olivia de Havilland, like you said, she was at Warner Brothers, but she really wanted to play Melanie, and was approached by George Cukor (allegedly after he asked her sister Joan Fontaine to take the role), and they acted out a scene for David Selznick in an unofficial test. I’m not sure how Selznick worked it out with WB, but clearly he did. Currently modern releases of GWTW are managed by Warner Brothers, so maybe this was part of a deal they made (WB had originally offered Bette Davis, Errol Flynn and Olivia de Havilland if they could distribute the film but Selznick declined) - but I really don’t know. I believe on the special edition DVD features this casting issue is discussed more in-depth … I think Olivia had the help of some big studio exec’s wife in negotiations, if I recall.
Leslie Howard was kind of wrangled into GWTW; I’m not sure how the studio issue was managed, but he was promised an associate producer gig for Selznick’s Intermezzo (1939) because he was personally reluctant. Maybe WB was kind of insisting he take it as part of a deal for de Havilland, which is why Selznick had to sweeten the deal - but don’t quote me on that.